Skip to content

Latest commit

History

History
7 lines (4 loc) 路 704 Bytes

README.md

File metadata and controls

7 lines (4 loc) 路 704 Bytes

Automatically stop a Shiny app when closing the browser tab

Dean Attali, July 2015

When developing a Shiny app and running the app in the browser (as opposed to inside the RStudio Viewer), it can be annoying that when you close the browser window, the app is still running and you need to manually press "Esc" to kill it. By adding a single line to the server code session$onSessionEnded(stopApp), a Shiny app will automatically stop whenever the browser tab (or any session) is closed.

Note that this can be useful for local development, but you should be very careful not to deploy this code in a real server because you don't want your real Shiny app to stop every time a user leaves the app.