Is it possible to get notified when the system is about to change its power state to sleep?
Something like
process.on('sleep', () => foo())
When going to sleep, the process does not get killed or exit, so answers from doing a cleanup action just before node.js exits do not suffer.