Here is the syntax of setInterval() function.
It is important to remember that setInterval returns the ID of the interval process on being called. You need to save it in case you want to stop setInterval call later.
var IntervalId = setInterval(fname, 10000);
Once you have the interval ID with you, you can call clearTimeout() function to stop the setInterval call of that interval ID.
Once you have stopped the setInterval call it is advisable not to recall it again, else, in some cases, it may start a new timer.
How to Store File Content in Shell Variable
How to Sort Array of Objects By Multiple Objects
How to Split String by Character