title: NodeJS clearTimeout() doesn't seem to work correctly?
body: <p>I have a timeout which basically kills the process after it's run for too long, however this is only if a certain condition hasn't been met by then. Should my condition be hit, I'm using <code>clearTimeout()</code> to clear the timeout, but it seems that the error and process kill persist.</p>
  
  <p>Here is my code snippet; the error is still printed out after 5 minutes even if the <code>clearTimeout()</code> is hit.</p>
  
  <pre><code>function poll(callback){
      var timeLimit = setTimeout(function(){
          if(log) log("Could not get a response from the command.", "error");
          process.exit(1);
      }, 300000);
      exec("some command", function(error, stdout, stderr){
          if(stdout){
              clearTimeout(timeLimit);
              // Do other stuff
          } else {
              setTimeout(function(){
                  poll(callback);
              }, 1000);
          }
      });
  }
  </code></pre>
  
  <p>I tested in browser and it seemed to work in a typical JavaScript console, but perhaps I'm doing something wrong above?</p>
  
  <p>If so, any help will be appreciated. The above is my exact code (aside from the command and error messages, of course) so if anything is wrong it should be visible above.</p>
  
  <p>Thanks in advance.</p>