Consider the below case,
1. There is a modal form to collect input from user.
2. User can close the dialog by clicking on - "Cancel" or close ui button.
4. Add a beforeClose listener to check if the user has entered any value.
5. If user has not entered any value, continue to end. Else go to 5.
6. Open a modal confirm, informing the user about unsaved data that might be lost. Two actions -
A. Confirm close and lose data
B. Cancel and return to form
7. If A is chosen, close the modal confirm, and call modal form ("close") API
8. If B is chosen, close the modal confirm
Fiddle link - http://jsfiddle.net/aravindbaskaran/wwdar/
Currently after step 7, step 4 is invoked again and keeps looping.
The requirement is to modify the close API to allow force close without firing the before close event.
A similar analogy can be made to that of setting a value to the input programmatically, which doesn't trigger the change event, unless programmatically triggered.
Hope this helps in understanding the need.