Fix null check on back button press