I want to know if it is possible to detect when a node.js process is closed through clicking the 'X' on Windows. If so then how. I have tried process.on("exit");
but that did not work.
Catch SIGHUP
/*
* Run this code and close the Window before the 10 seconds
*/
var x = setTimeout(function() { console.log('hello world') }, 10000);
process.on('SIGHUP', function() {
console.log('About to exit');
process.exit();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With