handle onClose event