Properly handle back button press.