I am using tmux to manage multiple terminal windows. Currently I have 2 windows open with multiple panes. I know that I have to use the prefix (for me it is ctrl+a) to enter commands.

How can I close the session from inside of tmux? What command would close the session (all windows and panes) and tmux at the same time?

  • 3
    To detach from tmux (leaving process running): unix.stackexchange.com/a/174443/178412
    – Lee
    Jul 17, 2019 at 11:39
  • 3
    One very handy way to kill multiple sessions at once is first go to the overview window (with Ctrl+a->s) and then press x with the target section selected, followed by y to confirm. No typing :kill-session, no rebinding
    – rtviii
    Jul 8, 2021 at 7:03
  • @rtviii yeah cool, but then a whole terminal becomes unresponsive, at least I have it in my Kitty
    – bora89
    Nov 24 at 13:46

6 Answers 6


Press your prefix (e.g. Ctrl+A or B, which is the default) and then : and type kill-session, then hit Enter. This will, as the name of the command suggests, kill the session.

  • 10
    exit can be used instead of kill-session too
    – alizeyn
    Mar 5, 2020 at 8:53
  • 9
    exit will only close, e.g., the bash that tmux has opened. When you only have one panel open this may also close the window - not so for two panels open within one window.
    – dgruending
    Oct 8, 2020 at 8:43
  • 3
    Here are useful bindings just in case someone stumbles on this issue. Add the following to your .tmux.conf bind C-x confirm-before -p "kill other windows? (y/n)" "kill-window -a" bind Q confirm-before -p "kill-session #S? (y/n)" kill-session
    – user79262
    Mar 31, 2021 at 23:15
  • 1
    A better way (AFAIK the correct answer to the OP): Ctrl+B, then & and confirm with y
    – Antonio
    Jul 2, 2022 at 16:57
  • 2
    @Antonio which kills the window and not the session. Jan 26 at 19:21

If you want to close session other than the current session (and hence keep tmux running; closing the current session as in @0xC0000022L's answer, also closes tmux even if other sessions are available), do the following in one of the tmux windows:

# tmux ls
keepMe: 1 windows (created Wed Jun 24 14:20:15 2015) [171x41]
otherSession: 1 windows (created Wed Jun 24 14:22:01 2015) [171x41]
3: 1 windows (created Wed Jun 24 14:23:28 2015) [171x41]

(assuming here that you're on keepMe session)
# tmux kill-session -t otherSession
# tmux kill-session -t 3

This deletes the "otherSession" or session number 3, and leaves tmux running, assuming you didn't have "otherSession" or number 3 session selected when you deleted them.

  • 4
    Or if you prefer using your prefix, ctrl + prefix followed by : and then type kill-session -t name or kill-session -t number. If you do this from within the session you want to kill reattach using tmux a.
    – Matijs
    Apr 14, 2016 at 10:03
  • Related: tmuxguide.readthedocs.io/en/latest/tmux/tmux.html
    – Artfaith
    Dec 4, 2021 at 18:13
  • Is it possible to use entire session name to kill the target session? I remember that -t will match on prefix of any length.
    – Niing
    Dec 16, 2021 at 15:39

TMUX Prefix (e.g. ctrl+b) + :kill-session


tmux kill-session (could run either from the inside of a session or the outside)

Both styles of invocation can use the flags:

-t target-session destroys the given session
-a destroys all sessions but the given one or the one you are attached to

Running kill-session from the outside of TMUX kills the last session you were attached to. -a inverts that.

In the event, that you have more than one session running you could kill all sessions at once with: kill-server.

  • This is similar to the current accepted answer, can you go into a little more detail on why your answer is different?
    – Burgi
    Dec 29, 2016 at 12:37
  • 2
    No one pointed out, that you could close all sessions with the kill-server command. I also liked to provide a little more depth on the flags for kill-session.
    – FSchndr
    Dec 29, 2016 at 14:34
  • 6
    +1: This answer is also the only one with the helpful -a to destroy all other sessions. May 24, 2017 at 13:53
  • This is the better answer. I wish this were on the top of the answers...
    – Blaszard
    Jul 4, 2018 at 11:31

One of the best way to do this interactively is by pressing ctrl+b,w to go to window mode then add tag by pressing t. then press capital X to kill all tagged window...

enter image description here

this is apparent when you have mouse enabled. enter image description here

  • 3
    Lovely animated image!
    – sunapi386
    Jan 19 at 1:01
  • thanks.. just screen recorded and converted to gif... Apr 18 at 11:29

If you want to kill one session and all its windows and panes conveniently, just press PREFIXs. Then navigate to the session and hit x and confirm with y.

Killing a session using prefix s and then x y

(^A is my prefix)

You can also tag more than one session using t and then killing the tagged ones with X.

If you kill the current session, tmux will be exited as well. If you don't wish to exit, simply switch a different session before killing the session in question.


Unfortunately there does not appear to be a simple default keybind to do this, possibly because it's an action you might want to be careful about though this could be addressed with a confirm dialogue.

One way is C-x : to get the tmux prompt and kill-session

As @Vaisakh-k-m pointed out C-x w gives you an interface to select windows across multiple sessions which you can select with the arrow keys and t to toggle the tagged status then X to kill the tagged windows and y to confirm this action.

This way there is no need to type a command at the prompt (accessed with C-x :) kill-server kills all sessions not merely the current one

If you'd like a custom kill session keybind @user79262 suggests these additions to your .tmux.conf:

bind C-x confirm-before -p "kill other windows? (y/n)" "kill-window -a"
bind Q confirm-before -p "kill-session #S? (y/n)" kill-session

You can close the current window with: C-x (Your prefix Ctrl+a in the case of the OP, Ctrl+b by default) then & and confirm with y This shortcut kills the window but not the current session unless your are in the last open window.

If you run tmux ls you'll see that with C-x d the session is still running in the background. You can re-attach to these background sessions with tmux a -t <session> where session is a name number.

  • 2
    & will kill the window, not the session. The session will only be killed, if it's the last window existing in the current session. Jan 28 at 17:32
  • Thx @Matrin Braun corrected accordingly Jan 29 at 22:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .