MainWindow: Correctly call on_leave on pages