fixing error on close for sockets