[BUG] Closing Terminal Tab Does Not Close Claude -> Excessive Memory Usage

Resolved 💬 6 comments Opened Mar 31, 2026 by winrid Closed May 10, 2026

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?

Closing a Konsole tab with Claude running puts it into a "stopped" state but it never exits. Here is the investigation using Claude itself. It says it's not handling SIGHUP properly. Claude suggested I file a bug report against itself :)

 what is taking so much memory on my system?                                                                                                                                                                                               
                                              
● Bash(free -h)                                                                                                                                                                                                                             
  ⎿                 total        used        free      shared  buff/cache   available                                                                                                                                                     
     Mem:            30Gi        23Gi       3.7Gi       2.2Gi       5.8Gi       6.9Gi                                                                                                                                                       
     Swap:          511Mi       511Mi       236Ki
                                                                                                                                                                                                                                            
● Bash(ps aux --sort=-%mem | head -30)                                                                                                                                                                                                      
  ⎿  USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
     winrid   1747166  373  9.1 4969440 2937456 ?     Sl   23:09   4:16 /home/winrid/Android/Sdk/emulator/qemu/linux-x86_64/qemu-system-x86_64 -avd tiny_device -gpu swiftshader_indirect -no-snapshot-load -no-audio                       
     winrid   1732171  102  7.1 10424272 2301044 ?    Ssl  22:59  11:16 /home/winrid/.sdkman/candidates/java/17.0.17-tem/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-     
     … +40 lines (ctrl+o to expand)
                                                                                                                                                                                                                                            
● You're using 23GB of 30GB RAM and swap is completely full. Here's the breakdown:
                                                                                                                                                                                                                                            
  ┌─────────────────────────┬────────┬───────────────────────────────────────────┐                                                                                                                                                          
  │        Category         │  ~RSS  │                   Notes                   │
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ Claude Code instances   │ ~6.3GB │ ~17 instances, most in stopped (Tl) state │
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ Android emulator (qemu) │ ~2.9GB │ tiny_device emulator                      │                                                                                                                                                          
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ Gradle daemons (2)      │ ~2.7GB │ Java 17 + Java 25, both at -Xmx2048m      │                                                                                                                                                          
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ TypeScript servers (2)  │ ~2.4GB │ tsserver for two projects                 │
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ Firefox + tabs          │ ~2.0GB │ Main process + 3 content processes        │
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ Kotlin compile daemon   │ ~500MB │ Idle, 2hr auto-shutdown                   │
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ plasmashell             │ ~684MB │ KDE desktop                               │
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ RustDesk                │ ~341MB │ Remote desktop                            │
  ├─────────────────────────┼────────┼───────────────────────────────────────────┤                                                                                                                                                          
  │ Node app                │ ~297MB │ node app in pts/36                        │
  └─────────────────────────┴────────┴───────────────────────────────────────────┘                                                                                                                                                          
                                                                  
  The biggest culprit is the ~17 Claude Code processes (~6.3GB combined). Most are backgrounded/stopped (Tl state) from previous sessions. You can reclaim a lot by killing the stopped ones:                                               
                                                                  
  # Kill all stopped (Tl) claude processes                                                                                                                                                                                                  
  kill 1917194 2481578 4104275 1359191 3379644 2214740 456267 1798161 2007339 1361939 2290664 3247639                                                                                                                                       
                                                                                                                                                                                                                                            
  You could also stop the Gradle daemons if you're not actively building:                                                                                                                                                                   
                                                                                                                                                                                                                                            
  gradle --stop                                                                                                                                                                                                                             
                                                                                                                                                                                                                                            
❯ but i only have 4 claude code instances running? are they not closing after i close the konsole tab?                                                                                                                                      
                                                                                                                                                                                                                                            
● Right - the 4 active ones are in Sl+ state (attached to a terminal). The other ~13 are in Tl state (stopped by signal, not terminated). When you close a Konsole tab, the shell sends SIGHUP to child processes, but it seems Claude is   
  catching/ignoring it and getting stopped instead of exiting. So they just pile up as zombies eating ~300-400MB each.
                                                                                                                                                                                                                                            
  Kill the stopped ones now:                                                                                                                                                                                                                
   
  kill 1917194 2481578 4104275 1359191 3379644 2214740 456267 1798161 2007339 1361939 2290664 3247639                                                                                                                                       
                                                                                                                                                                                                                                            
  To prevent this going forward, you could add to your ~/.bashrc or ~/.zshrc:                                                                                                                                                               
                                                                                                                                                                                                                                            
  # Ensure child processes get killed on shell exit                                                                                                                                                                                         
  shopt -s huponexit  # bash                                                                                                                                                                                                                
                                                                                                                                                                                                                                            
  Or if you want to be more aggressive, you could add a Konsole profile pre-close hook, but huponexit should help for most cases. If that still doesn't work, the issue may be that Claude is trapping SIGHUP - in which case you'd want to 
  file an issue at https://github.com/anthropics/claude-code/issues.                                                                                                                                                                        
                                                                                                                                                                                                                                            
❯ i ran that, memory looks the same?                                                                                                                                                                                                        
                                              
● Bash(free -h)                                                                                                                                                                                                                             
  ⎿                 total        used        free      shared  buff/cache   available                                                                                                                                                       
     Mem:            30Gi        23Gi       3.5Gi       2.2Gi       6.1Gi       7.0Gi                                                                                                                                                       
     Swap:          511Mi       511Mi        52Ki                                                                                                                                                                                           
                                                                                                                                                                                                                                            
● Bash(ps aux --sort=-%mem | head -10)                                                                                                                                                                                                      
  ⎿  USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND                                                                                                                                                             
     winrid   1747166  255  9.2 4926280 2969092 ?     Sl   23:09   7:13 /home/winrid/Android/Sdk/emulator/qemu/linux-x86_64/qemu-system-x86_64 -avd tiny_device -gpu swiftshader_indirect -no-snapshot-load -no-audio
     winrid   1732171 90.0  7.1 10426184 2317500 ?    Ssl  22:59  11:25 /home/winrid/.sdkman/candidates/java/17.0.17-tem/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-     
     … +23 lines (ctrl+o to expand)                                          
                                                                                                                                                                                                                                            
● The stopped Claude processes are gone from the top list, but Linux doesn't always release memory immediately - it keeps it as cache. The "available" column (7.0GB) is what actually matters for whether you'll run out.                  
                                                                             
  Let me check if they're truly gone and what's still eating memory:                                                                                                                                                                        
                                                                                                                                                                                                                                            
● Bash(ps aux | grep '[c]laude' | wc -l && ps aux | grep '[c]laude' | awk '{sum += $6} END {printf "Total Claude RSS: %.0f MB\n", sum/1024}')                                                                                               
  ⎿  32                                                                                                                                                                                                                                     
     Total Claude RSS: 9288 MB                                                                                                                                                                                                              
                                                                                                                                                                                                                                            
● Bash(ps aux | grep '[c]laude' | awk '{printf "%s %s %s %.0fMB %s\n", $2, $8, $9, $6/1024, $11}' | sort -t'M' -k1 -rn)
  ⎿  4104275 Tl Mar29 401MB claude                                                                                                                                                                                                          
     3974769 Tl Mar29 263MB claude                                                                                                                                                                                                          
     3626766 Tl Mar29 224MB claude                                                                                                                                                                                                          
     … +29 lines (ctrl+o to expand)                                                                                                                                                                                                         
                                                                                                                                                                                                                                            
● They didn't die - kill sends SIGTERM but stopped (Tl) processes can't process signals until resumed. They need kill -9 (SIGKILL). There are 28 stopped Claude processes eating ~9GB total.                                                
                                                                             
  Your 4 active ones are PIDs: 1642081, 1718654, 1741666, 1748365. Let's force-kill the rest:                                                                                                                                               
                                                                                                                                                                                                                                            
● Bash(ps aux | grep '[c]laude' | awk '$8 == "Tl" {print $2}' | xargs kill -9)                                                                                                                                                              
  ⎿  (No output)                                                                                                                                                                                                                            
                                                                                                                                                                                                                                            
● Bash(free -h)                                                                                                                                                                                                                             
  ⎿                 total        used        free      shared  buff/cache   available
     Mem:            30Gi        16Gi        10Gi       2.2Gi       6.2Gi        14Gi                                                                                                                                                       
     Swap:          511Mi       364Mi       147Mi                                                                                                                                                                                           
                                                                             
● 7GB freed - down from 23GB to 16GB used, and available went from 7GB to 14GB. Swap is draining too.                                                                                                                                       
                                                                                                                                                                                                                                            
  The problem is that Claude processes in stopped (Tl) state ignore SIGTERM - they need SIGKILL. And closing a Konsole tab is stopping them rather than terminating them. This is likely a Claude Code bug where it doesn't handle SIGHUP   
  properly. Worth reporting at https://github.com/anthropics/claude-code/issues.     

What Should Happen?

claude should exit and release memory

Error Messages/Logs

Steps to Reproduce

  1. open claude in Konsole
  2. close the tab
  3. claude does not exit

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.88 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

I'm not sure why Konsole is not an option under Terminal/Shell. It's included with most KDE distros.

View original on GitHub ↗

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