Properly handle back button.