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

# applicationShouldTerminate(_:)

Returns a value that indicates if the app should terminate.

```
@MainActor optional func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply
```

## Parameters

`sender`

The application object that is about to be terminated.

## Return Value

One of the values defined in [`NSApplication.TerminateReply`](/documentation/AppKit/NSApplication/TerminateReply) constants indicating whether the application should terminate. For compatibility reasons, a return value of <doc://com.apple.documentation/documentation/Swift/false> is equivalent to [`NSApplication.TerminateReply.terminateCancel`](/documentation/AppKit/NSApplication/TerminateReply/terminateCancel), and a return value of <doc://com.apple.documentation/documentation/Swift/true> is equivalent to [`NSApplication.TerminateReply.terminateNow`](/documentation/AppKit/NSApplication/TerminateReply/terminateNow).

## Discussion

This method is called after the application’s Quit menu item has been selected, or after the [`terminate(_:)`](/documentation/AppKit/NSApplication/terminate(_:)) method has been called. Generally, you should return [`NSApplication.TerminateReply.terminateNow`](/documentation/AppKit/NSApplication/TerminateReply/terminateNow) to allow the termination to complete, but you can cancel the termination process or delay it somewhat as needed. For example, you might delay termination to finish processing some critical data but then terminate the application as soon as you are done by calling the [`reply(toApplicationShouldTerminate:)`](/documentation/AppKit/NSApplication/reply(toApplicationShouldTerminate:)) method.

## See Also

[`terminate(_:)`](/documentation/AppKit/NSApplication/terminate(_:))

Terminates the receiver.



---

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)