Correct usage of the TCP mixin

This main fixes the usage of the TCP mixin, like rescuing exceptions and making sure it disconnects properly.

Please make sure I'm not breaking your code.