Exit shell with shortcut (not typing exit) that closes session properly

Ctrl-D will exit a shell in many cases. It is quicker than typing exit Enter. It's still not a single command to terminate everything, but holding Ctrl and hitting D several times is easier and faster. Not sure how valuable this is for your use case.

Discussed in detail here.


Typing ~. actually does the trick of closing all the "nested" connections through to the deepest.

It does so with the amicable exit you want as long as all your shells are configured to handle SIGHUP as a graceful death. Bash does so by default. You can easily check the amicable exit for your set-up by e.g. seeing whether the .bash_history files of your deeper sessions get properly updated after the ~., or if you set your bash-es not to update .bash_history upon exit then you might set a trap on the EXIT event (or in your ~/.bash_logout) with a command that writes something somewhere and later see whether it got executed.

Besides, I’m not sure what you mean by "exit all sessions in current shell". Each interactive bash is just one session, and the commands you type go always only to the deepest shell of the ProxyJump chain. If you meant "the background jobs in the current shell", bash does send SIGHUP to all its jobs on receiving SIGHUP by the ssh daemon upon the ~. , therefore such exit should be fully amicable if those running jobs react properly to a SIGHUP.