Fix crash when hitting back button