This issue could happen when you (somehow) get disconnected from an action SSH session. It is annoying as Ctrl+c, Ctrl+z nor Ctrl+d have no effect.
Apparently, we can use escape sequences as the workaround by hitting Enter, ~, . sequentially, and hit Enter to send the sequence.
Supported escape sequences:
~. - terminate connection (and any multiplexed sessions)
~B - send a BREAK to the remote system
~C - open a command line
~R - Request rekey (SSH protocol 2 only)
~V/v - decrease/increase verbosity (LogLevel)
~^Z - suspend ssh
~# - list forwarded connections
~& - background ssh (when waiting for connections to terminate)
~? - this message
~~ - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)
Moreover, we can hit ~ X times to kill SSH session on layer X and keep the X-1 layer intact.
Source: https://askubuntu.com/questions/29942/how-can-i-break-out-of-ssh-when-it-locks