Do not quit unconditionally when main window is closed
This appears to be a consequence of commits 3e34c9f0 and 22d1bab9. When the system tray icon is active, closing the main window should merely hide it but keep KMail running in the background. However, the test "if (KMMainWidget::mainWidgetList())" in KMKernel::canQueryClose() seems to be incorect, it is saying "if there is a main window, then allow the close". The effect is that KMail quits when the window is closed.
The test may have been incorrect for a long time, but masked by the second part of the conditional "and if there is more than one main window" before commit 3e34c9f0. Most users will only have one KMail main window open and so will never satisfy the condition.
Reversing the test restores the correct behaviour, so that KMail keeps running in the background (with the system tray icon shown if enabled) when the main window is closed.