My last week was a nightmare. The problem on handling close event in Firefox and Safari is the most tricky code I had ever encounter in my life.
Interestingly this is working find in IE except Firefox and Safari. Asking around in StackOverflow and I got this so called 'special handling' on Firefox and Safari. This piece of code is required in order to get the click event work and it is also support IE version greater than 8.