# capture-exit[](https://ci.appveyor.com/project/embercli/capture-exit/branch/master)[](https://travis-ci.org/ember-cli/capture-exit)Allow cooprative async exit handlers, we unfortunately must hijackprocess.exit.It allows a handler to ensure exit, without that exit handler impeding othersimilar handlersfor example, see: [sindresorhus/ora#27](https://github.com/sindresorhus/ora/issues/27)Differences between `process.on('exit')` and `captureExit.onExit(...)` => https://github.com/ember-cli/capture-exit/issues/12### Installation```shyarn add capture-exit// ornpm install--save capture-exit```### Usage```js// as early in startup as possiblerequire('capture-exit').captureExit();// when you want to schedule some work on exit:functiononExit(){returnsomething.processWillExit();// you can return promises, which will pause exit until fulfilled}require('capture-exit').onExit(onExit);// add an exit handlerrequire('capture-exit').offExit(onExit);// allows one to remove an exit handle if it is not longer required```