Added element to onClose function