title: How to avoid onbeforeunload preventing Watir test from exiting
body: <p>I have a webpage that uses onbeforeunload to prompt the user for confirmation whenever they try and navigate away from the page. This confirmation even fires when the browser window is closed.</p>
  
  <p>My problem is that this prompt is preventing Watir from closing IE at the end of a test run, at least until I manually intervene and click "OK".</p>
  
  <p>How can I write my tests such that Watir automatically dismisses this prompt, even if the test fails? I'm thinking there might be some conditional logic in the test teardown method, but I need help interacting with the popup.</p>
  
  <p><b>Note</b>: I have a <a href="https://stackoverflow.com/questions/1758699/how-to-click-on-onbeforeunload-prompt-in-watir-test">different question</a> pertaining to interacting with the onbeforeunload prompt when it is created by a click event. This question is about handling that popup when it is created by a request to close the window.</p>