Is there any way to launch async operation in node js upon exit?

Node js module during the operation requests some resources on remote service, that better be released when it exits. We know that there is very nice:

process.on('exit', function() {
    // ...
});

But then it is said that it won't wait for any async operations to complete. So the question is if there's any workaround (there should be some, since it's quite widespread usage case)? Maybe one could start separate process or something?..

Only workaround I've seen is adding a wait loop and not finishing/returning from the .on('exit', function until a property has been updated globally. Totally a bodge-job design-wise, very bad practice, but I've seen it work for short calls (I think there is some timeout but I never bothered to look into the details).

I think you could/should do clean-up before on('exit') by listening for ctrl-c signal like in this post.