How does node.js monitor the forced exit of the program?

  node.js, question

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?

https://nodejs.org/api/process.html#process_event_exit

This event is only emitted when node exits explicitly by process.exit() or implicitly by the event loop draining.