Add Ctrl-C support to server, and workaround socket close issue.

Socket raised 'TearDownError', but this was undefined. Removed it.