SessionEnd/Stop hooks should fire on /exit command

Resolved 💬 4 comments Opened Mar 18, 2026 by DarkCatharsis013 Closed Apr 18, 2026

Description

Hooks configured for session end events do not fire when the user exits via the /exit slash command. The hardcoded "Goodbye!" message always displays with no way to customize or extend the exit behavior.

Related to #17885 (closed as stale) and #12755.

Use Case

I want to display a custom farewell message when exiting Claude Code. I configured a Stop hook in ~/.claude/settings.json:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "echo '{\"systemMessage\": \"Hasta la vista, baby! 🤖\"}'",
            "timeout": 5
          }
        ]
      }
    ]
  }
}

This never fires on /exit. The hardcoded "Goodbye!" always appears instead.

Expected Behavior

At minimum, one of the following should work:

  1. Stop hook fires before the goodbye message on /exit
  2. SessionEnd hook fires and its output is displayed before process termination
  3. A new Exit or PreSessionEnd hook event that runs before the process exits and can output to the terminal

Current Behavior

  • /exit → prints hardcoded "Goodbye!" → process terminates immediately
  • No hook event fires
  • Ctrl+D reportedly fires SessionEnd but /exit does not (#17885)

Environment

  • Windows 11
  • Claude Code CLI (latest)

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗