Browser close event in javascript example