how to put shiny app to sleep in shinyapp.io, once the webpage is closed

I made a shiny app which I deployed on shinyapp.IO. Since, I am using free account of shinyapps.io which gives 25hrs/month of application usage. Hence, I am trying to conserve application usage time.
For which I am trying to stop the app once the window is closed. I am using this command, found in the internet.

library(shinyjs)

jscode <- "shinyjs.closeWindow = function() { window.close(); }"

ui <- fluidPage(
  useShinyjs(),
  extendShinyjs(text = jscode, functions = c("closeWindow")),
  actionButton("close", "Close window")
)

server <- function(input, output, session) {
  observeEvent(input$close, {
    js$closeWindow()
    stopApp()
  })
}

# I have even tried stopApp() above js$closewindow()

If I deploy the app locally then the app closes in RStudio. But, when deployed vi shinyapps.IO the app status remains online even after using closeWindow button.

Setting idle time to minimum 5 min in shinyApps.IO will result use of 2 hr 30 min. Hence, I can effectively use the app for 22 hr 30 min/month. i.e. almost for 21-22 days. If used approx. 1hr/day.

Can't pay for the app, Not earning yet.

Is there anyway I can stop app, once app window is closed.

Thank You for your support.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.