Kennith,
I was having the same problem with my custom dialog under IE9. Other browsers could close fine, but IE9 would popup the message and would close the main page and not just the dialog.
Anyway - the above fix worked for me.
Thanks!
The Analytical Group