Since node 6, stdio is non blocking by default. Besides having several advantages, one obvious disatvantage is that sometimes the program exits before all output has been printed. This module changes it back to blocking!
Include this at the top of your process:
require('blocking-stdio')();
Do NOT include this in a library. This module modifies global state and thus should ONLY be used in an application. Don't modify global stuff in libraries, people.
Thanks @isaacs! https://twitter.com/izs/status/732317861067153408.
MIT