No need to close your terminal tab anymore (or furiously hitting your keyboard) when your SSH session frozen. SSH has an escape sequence that will let you properly close the connection and give you back the prompt. In order, type: Return, ~, .
That’s it! This will send an escape sequence to your local SSH socket and close the connection.
SSH has more escape sequences under the hood, hit Return ~ ? to display the full list:
~?
Supported escape sequences:
~. - terminate session
~B - send a BREAK to the remote system
~R - request rekey
~# - list forwarded connections
~? - this message
~~ - send the escape character by typing it twice