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?


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.

| improve this answer | |
  • 6
    exit can be used instead of kill-session too – ALIZEYN Mar 5 at 8:53
  • 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 at 8:43

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.

| improve this answer | |
  • 1
    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 '16 at 10:03

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.

| improve this answer | |
  • 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 '16 at 12:37
  • 1
    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 '16 at 14:34
  • 2
    +1: This answer is also the only one with the helpful -a to destroy all other sessions. – AaronDanielson May 24 '17 at 13:53
  • This is the better answer. I wish this were on the top of the answers... – Blaszard Jul 4 '18 at 11:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.