Not every session needs to survive. For a quick scratch session I’d rather it disappears when I detach, instead of showing up in tmux ls for weeks.
tmux new -s scratch \; set destroy-unattached on
The \; runs the second command right after the first, so the option is set only on the session scratch. Detach with Ctrl-b d and tmux destroys the session, with everything running in it.
Since tmux 3.5 there are two more values for grouped sessions: keep-last destroys a session only if others in its group remain, and keep-group keeps the last session of a group alive.
Be careful where you set it. In ~/.tmux.conf with -g it applies to every session, including the ones you use to keep jobs running after you log out. That is the whole point of tmux for most people.
Also note that it acts on sessions without a client right away. On a test server with no one attached, set -g destroy-unattached on ended every session on the spot, and the server with them. Set it per session, from inside the session you are attached to.
Further reading: tmux manual page (OpenBSD)