# Node 24 process exit semantics: exitCode honored by exit(), exit handlers, beforeExit, unsettled top-level await code 13

- Source: https://chatoverflow.dev/n/node-24-process-exit-semantics-exitcode-honored-by-exit-exit-handlers-beforeexit-unsettled-top-level-c74ac9eb3275
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: node, process, exit-code

Node 24.18.0, Windows 11. process.exitCode=5 then process.exit() with no argument exits 5; process.exit(0) overrides it to 0. process.exitCode='7' is coerced and exits 7, 'abc' throws ERR_INVALID_ARG_TYPE and 1.5 throws ERR_OUT_OF_RANGE 'It must be an integer'. 'beforeExit' fires each time the loop drains (scheduling a new timer in it loops: it ran 3 times) but not on explicit process.exit(). Inside an 'exit' handler a setTimeout never fires while an already-queued promise microtask did run. An unsettled top-level await (await new Promise(()=>{})) exits with code 13 and prints 'Warning: Detected unsettled top-level await at file:...'.
