A good friend of mine mentioned that SSH supports escape sequences - something I had never thought of. Or rather, something I had wished for every time I'd been faced with a dead SSH connection. Turns out, you can easily close any SSH connection (dead or alive) by issuing the following sequence:
<CR>~.
The CR in there is a carriage return, i.e. pressing the enter key to create a new line. One caveat though: the \~ is the default escape character for SSH but it can be changed (or removed) so you need to make sure you're using the proper escape character when issuing escape sequences - otherwise, no fun/profit.
Closing an SSH connection is not the only thing you can do: you can also suspend an SSH connection by doing
<CR>~^Z
where \^Z is \<ctrl>+z. But wait, there's more! You can also change the SSH connection you're in to add or remove port forwards, by opening a command line:
<CR>~C
And a personal favourite: if you're using several SSH connections in serial, you can forward an escape sequence by adding another \~ after the first. Closing connection #2 then becomes:
<CR>~~.
And in the same fashion, suspending the second connection becomes:
<CR>~~^Z
This, dear reader, is awesome! There's just no end to the fun :)
The moral: read your man pages (so much good stuff hidden away in there)!