Many Ways to Skin a Window
Every couple of years, users of a Microsoft Windows application I wrote a long time ago start complaining that the application crashes when they exit from it. Every time it turns out that the reason is a Windows message that tells the application's main window to close in a way that was not originally foreseen.
Up to now I've collected four ways in which Windows can destroy a Window. I'm posting them here, because they may help other unfortunate puzzled souls. A window can be destroyed through the following messages.
(msg == WM_CLOSE) || (msg == WM_NCDESTROY) || (msg == WM_SYSCOMMAND && wParam == SC_CLOSE) || (msg == WM_NCLBUTTONDOWN && wParam == HTCLOSE);