Fix race condition in xmpp session cleanup.

Change-Id: I08b49ad9cadeb5c18406b76be4e97b6f1d3cf131