To get out of a frozen terminal due to ssh timeout. Type the following keys:
enter (return key) ~.
Add the following to your .ssh/config file. It sends a signal to the server every 240 seconds to keep the session.
Host *
ServerAliveInterval 240
Reference: http://www.metachunk.com/blog/dealing-osx-terminal-ssh-timeouts-0