I want to do some verification in my InitInstance() function after the main window is displayed. So I did the following:
m_pMainWnd = new CMainFrame();
Now, I find that the app crashes every time I try to close it (and that too after a long time and goes into NTDLL). Debug Monitor shows me a warning
 Warning: Destroying non-NULL m_pMainWnd
Now, if I place the checking code before i initialize the m_pMainWnd, everything remains Ok.