fix reconnection error when call client.end()

When the client is waiting for reconnecting, and then call `client.end()`, it will throw a error.