diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index e33003a0f35bff..510e9039b0e372 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -32,6 +32,16 @@ function libCoreRunFactory() { } ENV["DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"] = "true"; + + if (ENVIRONMENT_IS_NODE) { + const original_proc_exit = _proc_exit; + _proc_exit = (code) => { + if (!keepRuntimeAlive()) { + process.exit(code); + } + return original_proc_exit(code); + }; + } }, }, $CORERUN__postset: "CORERUN.selfInitialize()",