How do I exit a Node.js script gracefully when a condition is met?
To exit with success (0),
process.exit(0);
To exit with failure (1),
process.exit(1);
Default value is 0 (success), so for success you can just
process.exit();
Refer:
https://nodejs.org/docs/v0.5.4/api/process.html#process.exit