In a command prompt window, I have a running process. While the process is still executing, I click the (red) \'X\' in the corner of the command prompt window. The command p
The equivalent of SIGHUP is provided through the callback you register with SetConsoleCtrlHandler. Your callback function will be called on an arbitrary threadpool thread with dwCtrlType = CTRL_CLOSE_EVENT. You've got 5 seconds to clean-up, you cannot cancel the close.
Sample code is available in this MSDN article