[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [atExit](./bitburner.ns.atexit.md) ## NS.atExit() method Add a callback to be executed when the script dies. **Signature:** ```typescript atExit(f: () => void, id?: string): void; ``` ## Parameters
| Parameter | Type | Description |
|---|---|---|
| f | () => void | A function to execute when the script dies. |
| id | string | _(Optional)_ Callback ID. Optional, defaults to `"default"`. |