Break Loop Timeout JavaScript

var keepCalling = true;

setTimeout(function () {
  keepCalling = false;
}, 10000);

while ( keepCalling ) {
  // do something
}
Hirokami