QPID-2239: make sure the close() does not hand. Also handle authentication failures properly, QPID-2240. Patch by julien.lavigne