[BUG] Quitting via /quit or ctrl+d sometimes leaves shell in broken state

Status Fixed / completed
Reported on v2.1.83
Maintainer reply ✓ Yes — ashwin-ant
Activity 4 comments · opened Mar 27, 2026 · closed Apr 16, 2026
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

This one has been hard to hunt down the exact cause for. Occasionally, when quitting a claude code session (via /quit, ctrl+d, ctrl+c) i end up in a state where ctrl-sequences output characters to the prompt and backspace no longer works. The shell becomes fixed with reset, but ideally a shell should not become unusable after claude code exits.

What Should Happen?

Shell is usable normally after claude code exits.

Error Messages/Logs

No error messages, Ctrl-U for example spits out
;5u7;5u7;5u7;5u7;5u7;5u7;5u77;5u7;5u7;

Steps to Reproduce

Happens intermittently when exiting sessions, and I'm not sure of the exact condition. Seems to not happen exiting from a fresh session.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.83

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

Terminal is alacritty, OS is NixOS

View original on GitHub ↗

4 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/39096
  2. https://github.com/anthropics/claude-code/issues/39272
  3. https://github.com/anthropics/claude-code/issues/38761

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

baelter · 6 months ago

Root cause: Claude Code detects Alacritty via the ALACRITTY_LOG env var and then treats it as having full kitty keyboard protocol (CSI u) support. It's listed alongside Ghostty, kitty, iTerm, and WezTerm in the internal terminal capability map.

Alacritty's CSI u support is incomplete. When Claude Code enables the protocol and then exits (especially ungracefully), the terminal is left in CSI u mode. Bash/readline can't parse the sequences, so keystrokes like Ctrl+C produce 9;5u (tail of \e[99;5u) and Ctrl+D produces 0;5u (tail of \e[100;5u).

Fix would be to remove Alacritty from the CSI u capable terminal list, or ensure the protocol is always disabled on exit (e.g. sending \e[<u in a cleanup handler).

Workaround: unset ALACRITTY_LOG before launching claude so it falls back to generic terminal handling:

alias claude='ALACRITTY_LOG= command claude'

Or reset the terminal after exit with printf '\e[<u'.

ashwin-ant collaborator · 6 months ago

This issue was fixed as of version 2.1.85.

---
_Generated by Claude Code_

github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.