Added event to handle app closure