avoid crashes on reconnects swapping client.end() for client.quit()