Use `isClosing` to represent if a socket has been closed