Wait for logout (bug 1106027)

It's the handler tied up here: so it's more generic that it sounds. I'll file a bug for some renaming to get rid of this.