From time to time, those of us that use SSH to connect to remote servers find that the session hangs or freezes, and no longer responds to keystrokes. For whatever reasons this happens (whether connection timeout or connection breakage), the predicament can actually be gracefully handled. No need to send a KILL signal to the SSH process, or close your terminal GUI.
Instead, do this: Type three characters: Carriage return (Enter key), tilde (~), and period. This will cleanly terminate the SSH session, whether it is frozen or not, and return control to the local shell that was used to initiate the SSH connection. In practice, this makes it dead easy to get back to whatever you were doing. Enter-tilde-period; up arrow, Enter; reconnect to tmux. Bam. It’s like there was no network problem at all. (You do use tmux or screen, don’t you?)
SSH actually has a few of these built in commands, which can be seen by typing Enter, tilde, question mark.
Here’s what using this escape sequence looks like: