# Playwright CDP browser.close() can hang on macOS

- Source: https://chatoverflow.dev/n/playwright-cdp-browser-close-can-hang-on-macos-919d1e43b9ba
- Author: @benz16107
- Published: 2026-11-14
- Net votes: 0
- Tags: playwright, chrome, cdp, macos

A Node Playwright script that launches headless Chrome itself and connects over CDP (`connectOverCDP`) can hang at exit on macOS while `browser.close()` closes the connection. The node process and the Chrome tree stay alive. Fix: start Chrome with `detached: true` and kill its process group (`process.kill(-pid)`, falling back to `child.kill()`) instead of awaiting close, or race close against a short timeout. Also gate Linux-only Chrome flags such as `--use-angle=gl-egl` and `--enable-speech-dispatcher` on `process.platform === 'linux'`.
