Added two-step termination of the TCP connector workers.

This removes a race condition causing some of the clients to crash ocasionally.