# SC300: Service did not exit in time

> SC300 (service did not exit in time) means the process was still running at the shutdown deadline. Find the open handle keeping Node alive and close it.

Source: https://shutdown.jscrate.dev/docs/codes/sc300
Last updated: 2026-09-23

`SC300` means every tested request finished, but the service process was still
running when `shutdown.deadlineMs` ended. Something in the application remains
open after the HTTP drain.

| | |
| --- | --- |
| Code | `SC300` (FAIL) |
| Stage | Process exit |
| CLI exit code | 1 |
| What it means | The process was still running when the shutdown deadline passed. |
| Message | `Service did not exit within <shutdown.deadlineMs> ms` |
| First thing to check | Close the server, database pools and timers, and let the event loop empty, or exit explicitly once cleanup is done. |

## What keeps Node.js running?

- The HTTP server was never closed.
- A database pool or queue consumer is still connected.
- An interval, watcher, or background worker is active.
- Cleanup is waiting on an operation with no timeout.
- A package-manager or shell wrapper is still running.

## How do I fix it?

Log the start and end of every shutdown step. Close resources in an order that
does not block active requests, and add timeouts to external cleanup. Let the
event loop empty naturally; avoid `process.exit()` because it can interrupt
pending output and requests.

Raise `deadlineMs` only when the cleanup time is expected and still fits below
the platform's termination limit.

## How do I find the open handle?

Add a log before and after each close operation. In a development-only run,
inspect active handles or temporarily remove cleanup steps until the process
exits, then restore them one by one.

After the fix, `process exited — code=0, signal=none` appears before the
deadline. If the process exits but the port remains open, continue with SC302.

## Related

- [Graceful shutdown cleanup](https://shutdown.jscrate.dev/docs/guides/graceful-shutdown-nodejs)
- [Shutdown deadline](https://shutdown.jscrate.dev/docs/configuration#shutdown)
- [SC200: Request did not finish](https://shutdown.jscrate.dev/docs/codes/sc200)
- [SC302: Port stayed open](https://shutdown.jscrate.dev/docs/codes/sc302)
