Skip to content

Shutdown handling for SIGTERM that drains connections, finishes in-flight requests, and releases resources cleanly.

CCM score
40 of 100
skills.sh installs
441
GitHub stars
396
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers SIGTERM and SIGINT handling, stopping new requests, waiting for in-flight work, and resource cleanup before exit
  • Includes a TypeScript Express quick start plus reference guides for Kubernetes, worker processes, database pools, PM2, and Flask
  • Enforces a configurable shutdown timeout (30 seconds in the example) and fails health checks while shutdown is in progress
  • Designed for containerized deployments, rolling updates, and zero-downtime restarts behind load balancers

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill graceful-shutdown -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Graceful Shutdown

Table of Contents

Overview

Implement proper shutdown procedures to ensure all requests are completed, connections are closed, and resources are released before process termination.

When to Use

  • Kubernetes/Docker deployments
  • Rolling updates and deployments
  • Server restarts
  • Load balancer drain periods
  • Zero-downtime deployments
  • Process managers (PM2, systemd)
  • Long-running background jobs
  • Database connection cleanup

Quick Start

Minimal working example:

import express from "express";
import http from "http";

class GracefulShutdownServer {
  private app: express.Application;
  private server: http.Server;
  private isShuttingDown = false;
  private activeConnections = new Set<any>();
  private shutdownTimeout = 30000; // 30 seconds

  constructor() {
    this.app = express();
    this.server = http.createServer(this.app);
    this.setupMiddleware();
    this.setupRoutes();
    this.setupShutdownHandlers();
  }

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Backend & APIs, DevOps & Cloud
First seen
Jun 3, 2026

Questions

What does the graceful-shutdown skill do?

The graceful-shutdown skill implements shutdown procedures that handle SIGTERM signals, drain connections, complete in-flight requests and clean up resources. It stops accepting new requests, waits for active work to finish, and closes database connections before the process exits.

When should I use the graceful-shutdown skill?

Use graceful-shutdown when deploying containerized applications, handling server restarts, or ensuring zero-downtime deployments. The skill also covers Kubernetes and Docker deployments, rolling updates, load balancer drain periods and process managers such as PM2 or systemd.

How do I install the graceful-shutdown skill?

Run npx -y skills add aj-geddes/useful-ai-prompts --skill graceful-shutdown -y inside your project. After installation, the graceful-shutdown skill gives your agent guidance for handling SIGTERM and draining connections in your server code.

Which frameworks does the graceful-shutdown skill have guides for?

The graceful-shutdown skill includes reference guides for Express.js, Kubernetes-aware shutdown, worker processes, database connection pools, PM2, and Python with Flask. Its quick start example uses an Express server written in TypeScript.

Where does graceful-shutdown sit in the Backend and APIs category?

The graceful-shutdown skill is listed in the Backend and APIs category on Claude Marketplaces, alongside entra-app-registration, neon, firebase-basics, firebase-auth-basics and workers-best-practices. It focuses on shutdown behavior specifically, rather than general API building.

More from aj-geddes/useful-ai-prompts

All 258

Similar to Graceful Shutdown

More Backend & APIs