How to close a tmux session
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.
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
-or-
# 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.
TMUX Prefix (e.g. ctrl+b) + :kill-session
or
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
.