Added guard on listener during activity close