clearTimeout() can stop the running timer based on the variable. Below code shows the simple example to stop running timer.

myVar = setTimeout(function, milliseconds);
clearTimeout(myVar);