UPDATE
So after reading both of your answers I realize there is no reliable way to determine when a browser window is closed. Originally I was
Firefox closes immediately after you click the X to close the browser. For some reason it 'forgets' to call the onunload event.