Close TCP connection when done.
Stop when server closes connection.

Fixes #2