Task manager internally uses the EndTask function. This functions sends a WM_CLOSE message to your application. If your application does not respond to that message and the user forces to terminate your Application, TerminateProcess is called on your process.