To disconnect from server properly and close XMPP and TCP connection you need to call:
client.disconnect();