From Visual Basic I knew the simple command “end” to exit the application. A search in MSDN with similar phrases did not lead to a solution how to end a MFC application. The solution is the command following command, which calls a WM_DESTROY message:

PostQuitMessage(0);