Skip to main content
Browse referenceAll guides
Back to Commands
Session Management

kill-session

Destroy the given session, closing any windows linked to it and no other sessions, and detaching all clients attached to it.

How kill-session works

kill-session ends a session for good. Every window that belongs only to that session is closed, the programs in it are stopped, and any attached terminals are detached or moved to another session, depending on the detach-on-destroy option. Use it when a project is done and you want its processes gone, not just hidden.

Without -t it kills the current session. -a turns that around and kills every session except the target, which is a fast way to clean up after a long day. A window that is also linked into another session survives, because it still belongs somewhere.

tmux 3.7 added -g, which kills every session in the target's session group in one go. -C does not kill anything; it only clears bell, activity, and silence alerts in the session's windows.

Synopsis

bash
tmux kill-session [-aCg] [-t target-session]

Options

FlagDescription
-aKill all sessions except the one specified by -t
-CClear alerts (bell, activity, silence) in all windows
-gKill all sessions in the same session group (tmux 3.7+)
-t target-sessionSpecify which session to kill

Examples

Kill the session named 'dev'

bash
tmux kill-session -t dev

Kill all sessions except the current one

bash
tmux kill-session -a

Kill all sessions except 'main'

bash
tmux kill-session -a -t main

Kill api and every session grouped with it (tmux 3.7 and later).

bash
tmux kill-session -g -t api

Kill every session that no terminal is attached to. #{session_attached} is the number of attached clients.

bash
tmux ls -F '#{session_name} #{session_attached}' | awk '$2 == 0 {print $1}' | xargs -n1 tmux kill-session -t

Default Keybinding

kill-session has no default key. Run it from a shell as tmux kill-session, type it at the command prompt (Ctrl+b then :), or give it a key with bind-key.

Common Mistakes

  • There is no undo. Unsaved work in editors inside the session is lost. Save first, or detach instead if you might need the session again.
  • Killing the last session also stops the tmux server, because the exit-empty option is on by default. The next tmux command starts a fresh server.
  • kill-session -a keeps the target session, and the target defaults to the current one. Run it from inside the session you want to keep, or name that session with -t.

Pro Tips

  • •Be careful - this permanently destroys the session
  • •Use 'tmux kill-server' to kill all sessions at once
  • •Consider detaching instead if you might need the session later