core: prevent reconnecting a ws when the page is unloading