close window when Shiny stops; move to rmarkdown::run