terminate
Terminate a Node.js Process based on the Process ID
exit-hook
Run some code when the process exits
@ladjs/graceful
Gracefully exit HTTP servers (Express/Koa/Fastify/etc), databases (Mongo/Mongoose), Bree job schedulers, and custom handlers.