Disconnect database processes if the application is closed

Can we do configuration at Rstudio connect level (so that we don't need to code for each application) to stop the queries which are executing and disconnect from the database, When an application hosted at Rstudio connect is timed out?