tmux session must exit correctly on clicking close button

How can a tmux session exit correctly i.e. completely on the quit/exit by way of clicking terminal window’s close button, as it’ll keep the tmux session remains on its OS pid

Asked By: HELP ME


One of tmux‘s design goals is that the session persists when you close the terminal.

So by default, if you want to close a tmux session, you must actively do so with the command:

tmux kill-session -t <session-name>

If you somehow wish to disable the default behavior, you can set the destroy-unattached option in your ~/.tmux.conf file, like this:

set-option -g destroy-unattached on

With this option set, tmux will automatically close any sessions not attached to a client.

Answered By: Artur Meinild
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.