Process | Node.js v15.14.0 Documentation
The 'beforeExit' event is emitted when Node.js empties its event loop and has no additional work to schedule. Normally, the Node.js process will exit when there is no work scheduled, but a listener registered on the'beforeExit' event can make asynchronous calls, and thereby cause the Node.js process to continue.
https://nodejs.org/api/process.html