Properly cleanup when leaving the dashboard page