Depending on the situation there are a couple of things you can do. You can call the function when you've finished completing the current function or you can set a boolean for the same thing.
function A(){
alert('run items in function A');
return fireNewFunctionWhenComplete()
}
or set a flag
/*global var*/
var functionBCompleted = false;
function B(){
alert('run items in function B');
return functionBCompleted = true;
}
function testFunctionComplete(){
if(functionBCompleted){
alert('function B Copmleted');
}
else{
alert('function B not run');
}
}
This is a very simple example and as @T.J. mentioned you can't interrupt a running process. However, you may want to take a look into the promises spec if you want to run something when an asynchronous operation has completed.