title: setInterval Doesn't Clear onbeforeunload
body: <p>I have an HTML file with a form that I'm trying to autosave. In a separate file I have my save function. The issue I'm running into is <code>intervalID</code> doesn't clear when navigating away from the page. If I go to another page I still get logs to the console. Why doesn't <code>clearInterval</code> run before the page unloads?</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      //Manage saving
      var intervalID
      $(document).ready(function() { 
          intervalID = setInterval(function(){save('stateBioEditor', '0', 'bioInfo')}, 120000);
      });
  
      window.onbeforeunload = function() {
          //goodbye
          save('stateBioEditor', '0', 'bioInfo');
          clearInterval(intervalID);
          return undefined;
      };
  &lt;/script&gt;
  
  &lt;form id="bioInfo" action="" enctype="multipart/form-data" method="post"&gt;
      &lt;!--Inputs--&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>function save(type, id, form) {
      console.log('saving');
      var tempData = $("form#" + form).serialize();
      console.log(tempData);
      var request = $.ajax({
          type: 'POST',
          data: tempData,
          url: 'file.php?type=' + type + '&amp;recID=' + id,
          success: function(response) {
              console.log(response);
          }
      });
  }
  </code></pre>