requestAnimationFrame() returns an ID which can be used to cancel the "request" later, using cancelAnimationFrame():
var id = window.requestAnimationFrame(function() { ... });
...
cancelAnimationFrame(id);Of course, this works on modern browsers.