core: keep track of opened connections and don't open twice. js: window unload handler