Ensure session data is persisted when closing