Threads close the socket as they leave