Added another fix for an IE8 JS error when leaving the page