How do I handle the close/x button in console apps when running in Windows Vista, 7, 2008?
I found that I can capture the event by using SetConsoleControlHandler but Windows force terminates the app after a second (or milliseconds). That second isn’t enough for my app to clean up.
If you detach the console in response, does it still close you down?
http://msdn.microsoft.com/en-us/library/ms683150(v=vs.85).aspx