I think that SIGKILL is SIGTERM in Windows, so if it is true then I am tracking this signal.

No, I did not try to terminate the console programmatically, I know it will work. I am interested in doing proper clean up when the console is terminated via "x"-closure. Do you think there is a way to do it?