useEffect(() => {
return () => clean_up();
}, [])
Will clean_up
be runned if use closes tab or switches to a different website?
No, and this is not particular to React. Once a document or window is closed (which includes being redirected to another page), no further JavaScript can execute in that window.
setTimeout
will not run after the page is closed or redirected either, and neither will any other APIs provided by any other libraries, if they run on the client-side.