Fix stack overflow after logout.