---
title: "windowShouldClose(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nswindowdelegate/windowshouldclose(_:)"
---

# windowShouldClose(_:)

Tells the delegate that the user has attempted to close a window or the window has received a performClose(_:) message.

## Declaration

```swift
@MainActor optional func windowShouldClose(_ sender: NSWindow) -> Bool
```

## Parameters

- `sender`: The window being closed.

## Return Value

Return Value true to allow sender to be closed; otherwise, false.

## Discussion

Discussion This method may not always be called during window closing. Specifically, this method is not called when a user quits an application.

## See Also

### Closing Windows

- [windowWillClose(_:)](appkit/nswindowdelegate/windowwillclose(_:).md)
