Stop paying for browser sessions you forgot to close
Every evening, find the cloud browsers left running by crashed or half-finished jobs, shut them down, and post the count to Slack.
Every day at 6pm, on a cron trigger, sweep my Kernel account for browser sessions that were left running and reclaim them before they cost me money and block new work. This is a fully deterministic workflow: list, filter by age, delete, log, format, post. There is no judgement step anywhere, so build it as a code workflow.
Start by calling Kernel's List Browser Sessions, filtered to running sessions. Page through the results rather than reading only the first page, so an account with many sessions is fully covered.
For each running session, work out its age by comparing its creation timestamp to the current time. If a session is older than the age threshold, which should default to 60 minutes and be exposed as a configurable value, call Delete Browser Session for that session id. Leave anything younger than the threshold alone, since those are most likely legitimate in-flight runs.
For every session reclaimed, append one row to a Google Sheets audit log using Append Values. Each row should carry the session id, the session name, the age at reclaim in minutes, and the timestamp of the sweep. Append to the same tab every night so the log accumulates. This log is the point of the workflow as much as the deletions are: it is what lets someone notice that one particular job leaks a session every single night, which is the actual root cause worth fixing.
Finish by sending a Slack message with Send a Message to a configured channel, containing three numbers: how many sessions are still running after the sweep, how many were reclaimed, and how many were swept in total. Post this message on every run, including clean runs where nothing was reclaimed, so the team can see the sweep is alive rather than silently broken.
Keep the age threshold and the Slack channel as the two obvious knobs to change, defined clearly at the top of the workflow. The target spreadsheet and tab for the audit log should be configurable too. If a delete call fails for one session, log it and carry on with the rest rather than aborting the whole sweep, and reflect the failure in the counts.
What does this prompt do?
- Checks your Kernel account every evening for browser sessions that are still running
- Closes any session that has been open longer than your chosen cutoff, which starts at one hour
- Records every session it closed in a Google Sheet, so you can spot the job that leaks one every single night
- Posts a short Slack update with three numbers: still running, reclaimed, and total checked, even when nothing needed closing
What do I need to use this?
- A Kernel account where your browser automations run
- A Google account and a spreadsheet to use as the audit log
- A Slack workspace and a channel for the nightly update
How can I customize it?
- Change the age cutoff. One hour is the starting point. Raise it if your jobs legitimately run long, lower it if browsers should never linger.
- Pick which Slack channel gets the nightly update, and who should be watching it.
- Change the run time, or point the audit log at a different spreadsheet or tab.
FAQs
Will this close browsers that are still doing real work?
What happens on a night when nothing needs closing?
Why bother keeping a spreadsheet log?
Do I need to be on a paid plan for this to be worth it?
Can I run the sweep more than once a day?
Related templates
When your flight moves, your calendar times get corrected automatically and you get a Slack note naming the meetings you're about to miss.
Every 15 minutes, forwarded phishing reports get traced back to the server that really sent them, with a verdict in Slack and the worst senders reported.
Every Monday, check every S3 bucket for public exposure, missing encryption and weak backup settings, then get the risks ranked in Slack.
Every weekday at 7am, sign in to the tender portals you track, filter new notices against your bid criteria, and open a deal for the ones worth chasing.
Every weekday at 4pm, spot the threads that went quiet, stage a ready-to-send nudge in your mailbox, and get a ranked Slack recap.
Every Monday, rank the week's matches by expected demand, put the big ones on your venue calendar, and post a rota-ready summary to Slack.
Stop paying for browsers nobody closed.
Set this up once and let it reclaim forgotten sessions every night while you sleep.