SSH connection - after some time I can't type anything
You have a NAT router or a similar stateful firewall between your client and the server. When you opened the TCP session, the firewall remembered that a TCP connection was created between your client port and the server port. As long as the firewall remembers the connection, it will continue passing packets between the client and the server.
The session "breaks" because the firewall forgets about the connection and stops passing packets through. The firewall may forget about the connection because it has a timeout on idle connections. Or it could forget because it has a limited amount of memory and too many new connections were being created for it to remember all of them.
ssh has some options to work around this by sending periodic "keep-alive" packets when the connection is idle. Look at the
For what it's worth, instead of closing the terminal window, you can abort the ssh session by typing Enter ~ . consecutively.