Add detect browser close js snippets