Handle Back button properly.