ssh sessions in xterms freeze for many minutes whenever they disconnect

Solution 1:

Tilda period should do what you want (~.). It must be the first thing typed after pressing enter, so press enter and then type it. Here is the manual entry for ssh:

 -e escape_char
         Sets the escape character for sessions with a pty (default: ‘~’).
         The escape character is only recognized at the beginning of a
         line.  The escape character followed by a dot (‘.’) closes the
         connection; followed by control-Z suspends the connection; and
         followed by itself sends the escape character once.  Setting the
         character to “none” disables any escapes and makes the session
         fully transparent.

ctrl-d might also work.

Edit: SSH has a lot of escape character commands built in. With an active SSH session open you can press [enter]~? to see a list of options. This is all in the man entry for ssh. If you don't already know about man entries... you will discover a world of amazingness! In the linux terminal type "man command" in this case "man ssh" without the quotes. It has lots of information. Press "q" to quit. You can also type "info ssh" if you like the info interface better.

Solution 2:

Something is holding the connection open, probably from some sort of forwarding. You can try to use Ctrl\ to force ssh to die, but in general you should try to figure out what is wedging it open.