fixed race condition on logout