[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
Workaround ✓ Mentioned in thread ↓
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
4 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Root cause: Claude Code detects Alacritty via the
ALACRITTY_LOGenv 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 produces0;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[<uin a cleanup handler).Workaround: unset
ALACRITTY_LOGbefore launching claude so it falls back to generic terminal handling:Or reset the terminal after exit with
printf '\e[<u'.This issue was fixed as of version 2.1.85.
---
_Generated by Claude Code_
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.