# capture-exit

> safely cleanup in signal handlers

Latest version **2.0.0** (published 2018-12-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install capture-exit
pnpm add capture-exit
yarn add capture-exit
bun add capture-exit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-12-21 |
| First published | 2016-11-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 6.* \|\| 8.* \|\| >= 10.* |
| Dependencies | 1 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Stefan Penner |
| Maintainers | ember-cli, hjdivad, rwjblue, stefanpenner |

## Links

- npm: https://www.npmjs.com/package/capture-exit
- Repository: https://github.com/stefanpenner/capture-exit
- Homepage: https://github.com/stefanpenner/capture-exit#readme
- Issues: https://github.com/stefanpenner/capture-exit/issues
- npm.io page: https://npm.io/package/capture-exit

## Dependencies (1)

- [rsvp](https://npm.io/package/rsvp.md) ^4.8.4

## Recent versions

- 2.0.0 (latest) — 2018-12-21
- 1.2.0 — 2017-01-16
- 1.1.0 — 2016-12-19
- 1.0.7 — 2016-12-08
- 1.0.6 — 2016-12-06
- 1.0.5 — 2016-12-06
- 1.0.4 — 2016-11-16
- 1.0.3 — 2016-11-15
- 1.0.2 — 2016-11-15
- 1.0.1 — 2016-11-15
- 1.0.0 — 2016-11-09

## README

# capture-exit

[![Build status](https://ci.appveyor.com/api/projects/status/8044m918rwic8b9n/branch/master?svg=true)](https://ci.appveyor.com/project/embercli/capture-exit/branch/master)
[![Build Status](https://travis-ci.org/ember-cli/capture-exit.svg?branch=master)](https://travis-ci.org/ember-cli/capture-exit)

Allow cooprative async exit handlers, we unfortunately must hijack
process.exit.

It allows a handler to ensure exit, without that exit handler impeding other
similar handlers

for 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

```sh
yarn add capture-exit
// or
npm install --save capture-exit
```

### Usage

```js
// as early in startup as possible
require('capture-exit').captureExit();

// when you want to schedule some work on exit:
function onExit() {
  return something.processWillExit(); // you can return promises, which will pause exit until fulfilled
}

require('capture-exit').onExit(onExit); // add an exit handler
require('capture-exit').offExit(onExit); // allows one to remove an exit handle if it is not longer required
```

---
_Source: https://npm.io/package/capture-exit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
