A Claude Code plugin that enables Claude to gracefully terminate its own session.
Works for both local CLI sessions and Claude Code Web (remote sessions).
See Installation Guide for all installation methods.
# Via marketplace (recommended)
# Follow marketplace setup: ../../docs/manual-installation.md
# Or via GitHub
claude plugins install github:nsheaps/ai-mktpl/plugins/self-terminate
# Or locally for testing
cc --plugin-dir /path/to/plugins/self-terminateClaude can simply execute the provided script:
~/.claude/plugins/self-terminate/bin/self-terminate.shThe skill provides detailed instructions for manual termination if needed.
Claude Code runs as a process that spawns subshells for Bash commands. The script:
- Identifies the parent process (Claude) via
$PPID - Verifies it's actually a Claude process
- Sends
SIGINTfor graceful termination
- SIGINT (2): Graceful interrupt, allows cleanup
- SIGTERM (15): Also graceful, but SIGINT is more conventional for user-initiated stops
- SIGKILL (9): Force kill, no cleanup - avoid unless necessary
This plugin works seamlessly in Claude Code Web (remote sessions):
- Automatically handles the containerized environment
- Respects stop hooks that validate git state
- Script traverses the full process tree (process_api → environment-manager → claude)
- Alternative methods available: idle timeout, close browser tab
For Claude Code Web sessions, stop hooks may prevent termination if:
- There are uncommitted changes
- There are unpushed commits
- There are untracked files
Ensure clean git state before terminating to avoid hook blocking.
bin/self-terminate.sh- Executable script for terminationskills/self-terminate/SKILL.md- Detailed skill documentation
MIT