fix cleanup of sockets