Graceful Shutdown
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
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 -yInstalls 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- Blue Green Deployment440
- Disaster Recovery Testing440
- ML Pipeline Automation439
- ML Model Explanation438
- Release Planning438
- Cohort Analysis437
- Intermittent Issue Debugging436
- Recommendation Engine436
- Mocking Stubbing434
- Server Side Rendering434
- Data Migration Scripts432
- Correlation Tracing430
- Dimensionality Reduction430
- Synthetic Monitoring429
- Canary Deployment428
- Model Monitoring428
- Model Deployment427
- Service Mesh Implementation427
- Data Replication Setup426
- Polyglot Integration426
- Azure Functions425
- Graphql Implementation425
- Multi Cloud Strategy420
- Distributed Tracing419
Similar to Graceful Shutdown
More Backend & APIscircuit-breaker-patternaj-geddes/useful-ai-prompts481 installsReusable circuit breaker pattern that stops cascading failures with states, fallbacks, and monitoring.
uptime-monitoringaj-geddes/useful-ai-prompts494 installsHealth check endpoints and status page guidance for tracking service availability across application dependencies.
express-productionbobmatnyc/claude-mpm-skills528 installsProduction-ready Express.js guidance covering middleware order, error handling, security hardening, testing, and PM2 deployment.
server-managementsickn33/agentic-awesome-skills782 installsPrinciples-based server operations guide covering process management, monitoring, logging, scaling, health checks, and security.