<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebExtensionContext/didCloseWindow(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKWebExtensionContext(im)didCloseWindow:"
  },
  "title" : "didCloseWindow(_:)"
}
-->

# didCloseWindow(_:)

Called by the app when a window is closed to fire appropriate events with only this extension.

```
func didCloseWindow(_ closedWindow: any WKWebExtensionWindow)
```

## Parameters

`closedWindow`

The window that was closed.

## Discussion

This method informs only the specific extension of the closure of a window. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

## See Also

[`didOpenWindow(_:)`](/documentation/WebKit/WKWebExtensionContext/didOpenWindow(_:))

Called by the app when a new window is opened to fire appropriate events with only this extension.

[`openWindows`](/documentation/WebKit/WKWebExtensionContext/openWindows)

The open windows that are exposed to this extension.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)