***

title: setupGracefulShutdown
slug: /reference/typescript/agents/agent-base/setup-graceful-shutdown
description: Register signal handlers for graceful shutdown, useful for Kubernetes and containerized deployments.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Static method that registers process signal handlers for `SIGTERM` and `SIGINT` so the
agent shuts down cleanly. This is especially useful in Kubernetes deployments where the
pod receives `SIGTERM` before termination.

Only registers handlers once, even if called multiple times.

## **Parameters**

<ParamField path="opts" type="object" toc={true}>
  Optional configuration.
</ParamField>

<Indent>
  <ParamField path="opts.timeout" type="number" default="5000" toc={true}>
    Shutdown timeout in milliseconds before the process exits.
  </ParamField>
</Indent>

## **Returns**

`void`

## **Example**

```typescript {3}
import { AgentBase } from '@signalwire/sdk';

AgentBase.setupGracefulShutdown({ timeout: 10000 });

const agent = new AgentBase({ name: 'support', route: '/support' });
agent.setPromptText('You are a helpful assistant.');
await agent.serve();
```