jQuery Dialog 'manual vs script' close event

jQuery Dialog 'manual vs script' close event

Hi,
 
I am using the jQuery dialog, and I have a close event hanlder as well .
Close event is firing even when I close the dialog using the script.
I want to differentiate between the dialog manual close (by clicking the x button) vs the script close.
Do I have any separate event or parameter which will give me the details?
 
Thanks,
Jesu Benin.