For AI agents: a documentation index is available at /llms.txt
Skip to main content

Close a browser session

Fully terminate a remote browser session and release all resources by calling browser.close() or sending a DELETE request to the session stop endpoint.

Disconnect without closing

Want to detach from a browser without terminating it so you can reconnect later? See Disconnect and Reconnect to a Browser for the graceful disconnect pattern.

Prerequisites

Steps

Closing a session shuts down the browser process and frees compute resources. Use browser.close() in framework code, or DELETE /session/{id} for REST-managed sessions.

Use the Session API to create a session, then explicitly terminate it with a DELETE request when finished.

View Full Code on GitHub

1. Create a session

curl -X POST "https://production-sfo.browserless.io/session?token=YOUR_API_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"ttl": 60000,
"stealth": true
}'

The response includes a stop field with the DELETE URL:

{
"id": "d2f5c3a1-8b4e-4c7a-9e6d-1a2b3c4d5e6f",
"browserQL": "https://production-sfo.browserless.io/chromium/bql?session=d2f5c3a1...",
"browserWSEndpoint": "wss://production-sfo.browserless.io/chromium?session=d2f5c3a1...",
"stop": "https://production-sfo.browserless.io/session/d2f5c3a1...?token=YOUR_API_TOKEN_HERE"
}

2. Close the session

curl -X DELETE "STOP_URL_FROM_STEP_1&force=true"

The force=true parameter ensures the session is terminated immediately, even if a browser is still connected.