title: Execute after setTimeout finished
body: <p>Probably not very suitable title, but the question is the following.</p>
  
  <p>I've got this piece of code </p>
  
  <p><code>var someprogram = function(){
      if(stopprocess) return;
      //do things 
      setTimeout(someprogram, 1000);
  }
  setTimeout(someprogram, 1000);</code></p>
  
  <p>Sofar it works. After some number ot iterations, lets say 12, stopprocess is true and whole thing stops. I want to do some more things after the return. So the question is what is the best way to rewrite the structute to be able to do so? Because I need the timeout, but I don't know how else to stop the whole thing without using a return-statement. Any ideas? (I have only one javascript file for this task)</p>