Synchronous logout to avoid race conditions with loading. Fixes #27.