fixed closing of sockets