Reset m_pMainWnd in wxMFCApp::ExitInstance() to avoid crash when deleting it again in OnMainWindowDestroyed() that could happen if ExitInstance() was called not because the main window was closed (normal case) but because wxApp::ExitMainLoop() was called, as it happens when an unhandled exception is thrown.