Fixed #5525 (Closing a socket file descriptor gives an error: Mismatching allocation and deallocation)