---
title: "close() | Grafana k6 documentation"
description: "Close the BrowserContext and all its pages."
---

# close()

Close the [browser context](/docs/k6/next/javascript-api/k6-browser/browsercontext/) and all its [pages](/docs/k6/next/javascript-api/k6-browser/page/). The [browser context](/docs/k6/next/javascript-api/k6-browser/browsercontext/) is unusable after this call and a new one must be created. This is typically called to cleanup before ending the test.

### Returns

Expand table

| Type            | Description                                                                                                                                                                                      |
|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `Promise<void>` | A Promise that fulfills when the [browser context](/docs/k6/next/javascript-api/k6-browser/browsercontext/) and all its [page](/docs/k6/next/javascript-api/k6-browser/page/)s have been closed. |

### Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const context = await browser.newContext();
  await context.newPage();

  await context.close();
}
```
