October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Close a Puppeteer Browser

Use await browser.close() to shut down Puppeteer’s browser and its pages. Choose disconnect(), page.close(), or context.close() when you need a narrower cleanup scope.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To close a Puppeteer browser and all its associated pages, use await browser.close(). Use await browser.disconnect() instead when you only want Puppeteer to stop controlling a browser that should remain open.

Close the whole browser

Call and await browser.close() when your script is finished with the browser. Puppeteer documents that this closes the browser and all associated pages. Awaiting the promise ensures the asynchronous close operation completes before your code continues.

As an Amazon Associate I earn from qualifying purchases.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com');
  // Do work with the page.
} finally {
  await browser.close();
}

The try/finally pattern makes cleanup run whether the work succeeds or throws. The documented operation is Browser.close().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the right cleanup scope

What you want to close Use Effect
The browser and its pages await browser.close() Closes the browser and all associated pages.
Puppeteer’s connection only await browser.disconnect() Leaves the browser process running and its pages open.
One page await page.close() Closes that page; it does not shut down the browser.
An isolated browser context await context.close() Closes that context and its pages. The default browser context cannot be closed this way.

Puppeteer’s browser management guide states: “Unlike browser.close(), browser.disconnect() does not shut down the browser or close any pages.”

Close a page or an isolated context

Close one page

Use await page.close() when the browser should stay available for other tabs. The method also accepts an optional { runBeforeUnload?: boolean } option, and returns a promise; see the Page.close() API.

Close an isolated context

Use await context.close() to close an isolated context and the pages it contains. This is useful when work in one context is finished but other browser contexts should remain. The default browser context cannot be closed using this method; see BrowserContext.close().

When to disconnect instead of close

Puppeteer can connect to a browser launched by another process. If that process owns the browser and should keep it running, call await browser.disconnect() to release Puppeteer’s connection. If your intention is to shut down the browser itself, use await browser.close().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not rely on browser.process() to obtain a process handle in every case: it returns null when the browser was reached through puppeteer.connect(). See the Browser.process() API.

Close a browser on cancellation or process signals

Puppeteer launch options let you associate browser cleanup with an AbortSignal; aborting that signal closes the browser. The options also document default handling for SIGHUP, SIGINT and SIGTERM, including browser close or kill behavior. These launch-time options are separate from choosing an explicit cleanup call in application code. Consult the LaunchOptions API for the version you use.

Troubleshooting browser cleanup

  • Chrome stays open after disconnect(): this is expected. Disconnecting leaves the browser and its pages running. Use await browser.close() if your code owns the browser and should shut it down.
  • Other tabs or pages close unexpectedly: browser.close() closes the entire browser and its associated pages. Use page.close() for one tab or close only the relevant isolated context.
  • You cannot close the default context: context.close() cannot close the default browser context. Close individual pages, or close the whole browser if that is the intended scope.
  • browser.process() returns null: this is documented when Puppeteer connected with puppeteer.connect(); do not treat it as a local process handle.
  • Cleanup is skipped when work throws: put the work in a try block and await browser.close() in finally.

Or skip the browser setup

If your goal is to capture a website rather than automate a browser yourself, ScreenshotNeo returns a screenshot or PDF from one GET request. For example, save a WebP capture with cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for request options. Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets. Bot checks, blank pages, failed loads and cache hits are not billed. An MCP server gives AI agents screenshot tools, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does Puppeteer close Chrome when I call browser.disconnect()?

No. It disconnects Puppeteer but leaves the browser process and pages open. Use browser.close() to shut the browser down.

Can I close just one Puppeteer tab?

Yes. Call await page.close(); the browser remains open.

Best Value
The SQL Programming Language: .
  • Used Book in Good Condition

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.