@scg82/exit-hook
Execute a callback when the process exits, passing the exit code (ESM/CJS)
when-exit
Execute a function right before the process, or the browser's tab, is about to exit.
exit-hook
Run some code when the process exits
signal-exit
when you want to fire an event no matter how a process exits.