Handle tabs caching and logout

My suggestion is here, which should allow you to achieve your underlying goal without abusing lifecycle events.