Make sure logout waits until user is actually logged out

Fixes #192