<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/close()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(im)close"
  },
  "title" : "close()"
}
-->

# close()

Removes the window from the screen.

```
func close()
```

## Discussion

If the window is set to be released when closed, a `release` message is sent to the object after the current event is completed. For an `NSWindow` object, the default is to be released on closing, while for an [`NSPanel`](/documentation/AppKit/NSPanel) object, the default is not to be released. You can use the [`isReleasedWhenClosed`](/documentation/AppKit/NSWindow/isReleasedWhenClosed) property to change the default behavior.

A window doesn’t have to be visible to receive the close message. For example, when the application terminates, it sends the close message to all windows in its window list, even those that are not currently visible.

The close method posts a [`willCloseNotification`](/documentation/AppKit/NSWindow/willCloseNotification) notification to the default notification center.

The close method differs in two important ways from the [`performClose(_:)`](/documentation/AppKit/NSWindow/performClose(_:)) method:

- It does not attempt to send a [`windowShouldClose(_:)`](/documentation/AppKit/NSWindowDelegate/windowShouldClose(_:)) message to the window or its delegate.
- It does not simulate the user clicking the close button by momentarily highlighting the button.

Use [`performClose(_:)`](/documentation/AppKit/NSWindow/performClose(_:)) if you need these features.

## See Also

[`orderOut(_:)`](/documentation/AppKit/NSWindow/orderOut(_:))

Removes the window from the screen list, which hides the window.



---

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)