Not a C++ developer... but you can check out these two articles:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.applicationexit(vs.80).aspxhttp://www.codeguru.com/forum/showthread.php?t=44992