Fix sync hang on logout/login. (#572)