As an example, if you want to handle SIGTERM in Node.js, then you can use the process module that is implicitly created in every Node.js process to handle the signals and to exit the application. To match the preceding Python example, a simple shut down immediately and exit bit of code might be as follows:
/** * SIGTERM handler to terminate (semi) gracefully */process.on(process.SIGTERM, function() { console.log('Received SIGTERM signal, now shutting down...'); process.exit(0);})