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

# performClose(_:)

Simulates the user clicking the close button by momentarily highlighting the button and then closing the window.

```
func performClose(_ sender: Any?)
```

## Parameters

`sender`

The message’s sender.

## Discussion

If the window’s delegate or the window itself implements [`windowShouldClose(_:)`](/documentation/AppKit/NSWindowDelegate/windowShouldClose(_:)), the window sends that message with the window as the argument. The window sends only one such message; if both the delegate and the window implement the method, the delegate receives the message. If the [`windowShouldClose(_:)`](/documentation/AppKit/NSWindowDelegate/windowShouldClose(_:)) method returns <doc://com.apple.documentation/documentation/Swift/false>, the window doesn’t close. If neither the window nor the delegate implement [`windowShouldClose(_:)`](/documentation/AppKit/NSWindowDelegate/windowShouldClose(_:)), or it returns <doc://com.apple.documentation/documentation/Swift/true>, this method invokes [`close()`](/documentation/AppKit/NSWindow/close()) to close the window.

If the window doesn’t have a close button or can’t close (for example, if the delegate replies <doc://com.apple.documentation/documentation/Swift/false> to a [`windowShouldClose(_:)`](/documentation/AppKit/NSWindowDelegate/windowShouldClose(_:)) message), the system emits the alert sound.

## See Also

[`styleMask`](/documentation/AppKit/NSWindow/styleMask-swift.property)

Flags that describe the window’s current style, such as if it’s resizable or in full-screen mode.

[`-  performMiniaturize:`](/documentation/AppKit/NSWindow/performMiniaturize(_:))

Simulates the user clicking the minimize button by momentarily highlighting the button, then minimizing 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)