Clearing cache when i press ctrl + C

i have code where i have a state variable when i am logged in as st.session_state[‘LOGGED_IN’] = True
.i want to make it so that when i close the app using ctrl + C my cache gets cleared?
even better would be if i close the tab it becomes False

Granted!

The whole point of using cache primitives is allowing your data and objects survive even after you close the tab. If you don’t want that, then do not use cache. Use session_state instead, it will get cleared when you close the tab.