Improved datepicker onClose event handling