Implement onClose event handler