---
title: "performClose(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nswindow/performclose(_:)"
---

# performClose(_:)

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

## Declaration

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

## Parameters

- `sender`: The message’s sender.

## Discussion

Discussion If the window’s delegate or the window itself implements 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(_:) method returns false, the window doesn’t close. If neither the window nor the delegate implement windowShouldClose(_:), or it returns true, this method invokes close() to close the window. If the window doesn’t have a close button or can’t close (for example, if the delegate replies false to a windowShouldClose(_:) message), the system emits the alert sound.

## See Also

### Related Documentation

- [styleMask](appkit/nswindow/stylemask-swift.property.md)
- [performMiniaturize(_:)](appkit/nswindow/performminiaturize(_:).md)

### Closing Windows

- [close()](appkit/nswindow/close().md)
- [isReleasedWhenClosed](appkit/nswindow/isreleasedwhenclosed.md)
