Stop then delay (trying to avoid eventual freezes)
Also always call client.stop() before leaving function