How can an MFC application terminate itself?

c++, mfc, visual-c++

Solution

Programatically Terminate an MFC Application

 void ExitMFCApp()
   {
        // same as double-clicking on main window close box
        ASSERT(AfxGetMainWnd() != NULL);
        AfxGetMainWnd()->SendMessage(WM_CLOSE);
   }

http://support.microsoft.com/kb/117320

Problem

What is the proper way for an MFC application to cleanly close itself?

Original source