Skip to main content

Overview

The Close Browser node terminates the browser instance and cleans up all associated resources. This node is typically used at the end of a workflow or when you need to restart the browser with different settings.
Browser instances are automatically closed when a workflow completes, so this node is optional in most cases.

When to Use

Use the Close Browser node when:
  • You need to restart the browser with different settings mid-workflow
  • You want to explicitly clean up resources before a long-running operation
  • You’re running multiple browser sessions and need to close specific ones
  • You want to ensure all browser data is cleared between workflow steps

Behavior

When executed, this node:
  1. Closes all open tabs and windows
  2. Terminates the browser process
  3. Cleans up temporary files and cache
  4. Releases all browser context references

Configuration

The Close Browser node has no configuration parameters. It automatically detects and closes the active browser instance from the workflow context.

Examples

Basic Usage

{
  "type": "closeBrowser",
  "data": {}
}

Restart Browser Pattern

Error Handling

The Close Browser node handles common error scenarios:
  • No browser running: Silently succeeds (no-op)
  • Browser already closed: Silently succeeds (no-op)
  • Force close on timeout: After 30 seconds, forcefully terminates the browser process

Implementation Details

The node is implemented by:
  1. Retrieving the PlaywrightManager from the execution context
  2. Calling the cleanup methods on all browser contexts
  3. Closing the browser instance
  4. Clearing context references
The browser close operation is asynchronous and waits for graceful shutdown. If the browser doesn’t respond within 30 seconds, it’s forcefully terminated.

Best Practices

// Use JavaScript Code node to conditionally close browser
if (context.getData('needsRestart')) {
  // Next node should be Close Browser
  context.setData('shouldClose', true);
}

Notes

Closing the browser will terminate all open tabs and lose any unsaved state. Ensure you’ve extracted all needed data before closing.
After closing the browser, you must use a new Start Browser node to perform additional browser operations.

Build docs developers (and LLMs) love