Add onClose method