catch any errors thrown by closing sockets