A replacement for process.exit that ensures stdio are fully drained before exiting.