How to exit tmux?

Quick Answer

To exit tmux completely, you can use the command tmux kill-server. To exit a specific session, use tmux kill-session or type exit in all panes. To temporarily detach without closing, press Ctrl+b d.

$ tmux kill-server

Detailed Explanation

There are multiple ways to exit tmux depending on what you want to accomplish: temporarily detaching from a session, closing a specific session, or shutting down the entire tmux server.

Temporarily detaching (session remains active):

  • Ctrl+b d - Detach from current session
  • Ctrl+b D - Choose which client to detach
  • tmux detach - From command line

Exiting individual components:

  • exit or Ctrl+d - Close current pane
  • Ctrl+b x - Kill current pane (with confirmation)
  • Ctrl+b & - Kill current window (with confirmation)

Closing specific tmux sessions:

  • tmux kill-session - Kill the current or last used session
  • tmux kill-session -t session-name - Kill a specific session by name
  • tmux kill-session -a - Kill all sessions except the current one
  • tmux kill-session -a -t session-name - Kill all sessions except the named one

Shutting down tmux completely:

  • tmux kill-server - Terminate the tmux server, closing all sessions

Warning

Using tmux kill-server will close ALL tmux sessions and any running processes within them. Make sure to save your work before using this command.

Pro Tip: Exit Without Confirmation

To skip the confirmation prompt when killing panes or windows, add these lines to your ~/.tmux.conf:

bind-key x kill-pane
bind-key & kill-window