• Version 2.0.0
  • Published
  • No dependencies
  • BSD-3-Clause license


npm i cleankill
yarn add cleankill
pnpm add cleankill


Hook SIGINT and cleanly shut down your async code



function close

close: () => Promise<void>;
  • Call all interrupt handlers, and call the callback when they all complete.

    Clears the list of interrupt handlers.

function interrupt

interrupt: () => void;
  • Calls all interrupt handlers, then exits with exit code 0.

    If called more than once it skips waiting for the interrupt handlers to finish and exits with exit code 1. If there are any errors with interrupt handlers, the process exits immediately with exit code 2.

    This function is called when a SIGINT is received.

function onInterrupt

onInterrupt: (handler: Handler) => void;
  • Register a handler to occur on SIGINT. The handler must return a promise if it has any asynchronous work to do. The process will be terminated once all handlers complete. If a handler throws or the promise it returns rejects then the process will be terminated immediately.

function promiseAllStrict

promiseAllStrict: (promises: Promise<any>[]) => Promise<void>;
  • Waits for all promises to settle, then rejects with the first error, if any.

Type Aliases

type Handler

type Handler = () => Promise<void>;
  • The type of a cleankill interrupt handler.

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (1)

Peer Dependencies (0)

No peer dependencies.


To add a badge like this badgeto your package's README, use the codes available below.

You may also use to create a custom badge linking to

  • Markdown
  • HTML
    <a href=""><img src="" alt=""></a>