Terminating asynchronous Javascript call started by setTimeout

Hello,

I have a set of tabs wherein I have embedded HTML DIV/IFrame tags that use Javascript.
The scrips are created with a CustomLayout and executed via the layout.getWindow().executeJavaScript( script )
function. The JavaScript executes a call to a “reLoadU()” function repeatedly via the use of setTimeout( reLoadU(), 10000)

I now have the following problem: when I close the Tab the "reLoadU() " keeps on executing. I
need a way to stop the time-out call. I can do this by storing the return from setTime and
terminating the time-out via the clearTimeout() call. But how can I do this from the event that
closes the tab? Can I access a common set of variables from various scripts executed
within different Vaadin components?

Is their any other way to go about this? For example, can I in the Javascript detect when the tab
is no longer active (in the application’s page)?

TIA