Call and await context.close() to close a Puppeteer BrowserContext and every page associated with it. It returns a Promise<void>. The default browser context cannot be closed; this method is for a context you created separately.
Close a context and its pages
Create a separate context, open pages in it, and close the context when that work is finished:
As an Amazon Associate I earn from qualifying purchases.
const context = await browser.createBrowserContext();
const page = await context.newPage();
try {
await page.goto('https://example.com');
// Do work with the page.
} finally {
await context.close();
}
The finally block makes the cleanup run whether the work completes normally or throws an error. Since closing the context also closes its associated pages, you do not need to call page.close() first when you intend to close the whole context. Close an individual page instead when you want the context and its other pages to remain open. See Puppeteer’s BrowserContext.close() reference.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →What happens to cookies and storage?
A newly created browser context is isolated from other contexts: it does not share cookies or cache, and its cookies and local storage are separate. Closing it disposes of the context and its pages. Puppeteer’s BrowserContext class reference and createBrowserContext() reference describe those context properties and lifecycle.
#1 Best Overall
Choose the right cleanup method
| Call | Effect | Use it when |
|---|---|---|
await context.close() |
Closes that context and all pages associated with it. | You are finished with one separately created context. |
await browser.close() |
Closes the browser and all associated pages. | You are finished with the entire browser. |
await browser.disconnect() |
Disconnects Puppeteer while leaving the browser process running. | You want to detach Puppeteer without shutting down the browser. |
These operations have different scopes; use the one that matches what should remain open. See Puppeteer’s Browser.close() and Browser.disconnect() references.
Common mistakes
- Trying to close the default context: Puppeteer does not allow the default browser context to be closed. Create a separate context with
browser.createBrowserContext()when you need a context you can dispose of. - Closing the browser when only one context should end:
browser.close()shuts down the browser and all associated pages. Usecontext.close()for context-scoped cleanup. - Closing pages one by one before closing the context: This is unnecessary if the whole context is being disposed of. Close pages individually only if the context should stay open.
- Disconnecting when you meant to stop the browser:
browser.disconnect()leaves the browser process running; usebrowser.close()to close it.
Version note
The official API pages consulted report different Puppeteer documentation versions: the BrowserContext.close() page reports 25.9.0, the context class and creation pages report 25.12.0, and the browser close and disconnect pages report 25.10.0. These are not evidence that every page describes one identical release. If version-specific behavior matters, check the API documentation corresponding to the Puppeteer package installed in your project.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Or skip the browser setup
If your goal is to get a website screenshot rather than manage a Puppeteer context, ScreenshotNeo can return an image or PDF from one API request. It is a different approach, not a way to close a Puppeteer context. For JavaScript, the supplied Node.js example is:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchQuick Recap
Best Value
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Rank #3
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo API documentation for request details. It removes cookie banners, newsletter popups and chat widgets before capture; bot checks, blank pages and failed loads are not billed; and its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for the free plan.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




