title: Detecting browser tab closure in Bokeh
body: <p>I want to detect if the user closes the browser tab that my application is running in. If this happens, I want to shut down a connected physical device. I'd like the sequence of events to be: user closes the browser tab (or browser), callback function is triggered, callback function closes device.</p>
  
  <p>I'm using the Bokeh Server to serve an application. I don't use CustomJS at all.</p>
  
  <p>Ideally, I'm looking for some kind of callback function (something like on_browser_close). I can't find anything in document or session that might do.</p>
  
  <p>Is there a way of detecting that the browser (tab) has been closed?</p>