1

I'm running a shiny app locally, starting it from a vbs script. Is there a way to end the app when the user closes the browser window? Something like end when it detects a connection reset. It looks like it can detect resets because i get the following when closing the browser while running the app from R:

ERROR: [on_request_read] connection reset by peer
Mathias711
  • 6,568
  • 4
  • 41
  • 58
Mark
  • 596
  • 1
  • 4
  • 14
  • You are looking for `onSessionEnded`, I think. See here: http://stackoverflow.com/questions/23276491/how-to-implement-a-cleanup-routine-in-r-shiny. OR alternative: https://www.r-bloggers.com/stop-shiny-and-close-browser-together/ – Buggy Jan 10 '17 at 15:21
  • Great, works well. I've added a comment with full solution. – Mark Jan 11 '17 at 01:54

1 Answers1

0

Thanks to a comment to my question, here is the solution:

I added this to my server.r file:

session$onSessionEnded(function() {
  quit()
})
Mark
  • 596
  • 1
  • 4
  • 14