In Express.js, is there someway of setting a callback function to be executed when the application shuts down?
The express team recommends the terminus package:
https://expressjs.com/en/advanced/healthcheck-graceful-shutdown.html