try to fix memory leaks

If the element is no longer in the DOM tree, stop its corresponding
setInterval in the next cycle.