You can use runtime.getruntime (). addshutdownook () in java. To monitor exit events, so you can do some state cleanup before exiting, and you can also capture forced exits in the IDE.
Why can’t I use process.on(‘exit’) in node.js to capture exit events in IDE?
This event is only emitted when node exits explicitly by process.exit() or implicitly by the event loop draining.