memory deallocation improvement

destroy the mutex structures in socket_free function