> ## Documentation Index
> Fetch the complete documentation index at: https://docs.narada.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# close

> Gracefully close the current browser environment

The environment `close` method gracefully closes the current browser environment. For local browser environments, you can also access the browser process ID and terminate the entire browser application.

## Method Signature

```python theme={null}
async def close(
    self,
    *,
    timeout: int | None = None,
) -> None
```

## Parameters

<ParamField query="timeout" type="int | None" default="None">
  Maximum time in seconds to wait for the environment to close. If `None`, uses the default system timeout.

  ```python theme={null}
  timeout=5      # Wait up to 5 seconds
  timeout=None   # Use default timeout
  ```
</ParamField>

## Return Value

This method returns `None` and completes when the environment has been closed.

## Example

<Tabs>
  <Tab title="Close Window">
    ```python theme={null}
    import asyncio

    from narada import Agent, BrowserEnvironment

    async def main():
        env = BrowserEnvironment()
        agent = Agent(environment=env)

        try:
            # Perform automation tasks
            response = await agent.run(
                prompt="Search for Python tutorials and open the first result"
            )

            print(f"Task completed: {response.text}")
        finally:
            # Close this specific browser environment
            await env.close()


    if __name__ == "__main__":
        asyncio.run(main())
    ```
  </Tab>

  <Tab title="Quit Entire Browser">
    ```python theme={null}
    import asyncio
    import os
    import signal

    from narada import Agent, BrowserEnvironment

    async def main():
        env = BrowserEnvironment()
        agent = Agent(environment=env)

        try:
            # Perform automation tasks
            response = await agent.run(
                prompt="Search for Python tutorials and open the first result"
            )

            print(f"Task completed: {response.text}")
        finally:
            await env.close()

        # Get the browser process ID (only available for locally launched browsers)
        pid = env.browser_process_id

        # Terminate the entire browser process
        if pid is not None:
            print(f"Terminating browser process with PID: {pid}")
            os.kill(pid, signal.SIGTERM)

    if __name__ == "__main__":
        asyncio.run(main())
    ```
  </Tab>
</Tabs>
