added: onClose function