---
title: "applicationWillTerminate(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsapplicationdelegate/applicationwillterminate(_:)"
---

# applicationWillTerminate(_:)

Tells the delegate that the app is about to terminate.

## Declaration

```swift
@MainActor optional func applicationWillTerminate(_ notification: Notification)
```

## Parameters

- `notification`: A notification named doc://com.apple.appkit/documentation/AppKit/NSApplication/willTerminateNotification. Calling the doc://com.apple.documentation/documentation/Foundation/NSNotification/object method of this notification returns the NSApplication object itself.

## Discussion

Discussion Your delegate can use this method to perform any final cleanup before the app terminates.  The app will terminate after this method returns. note: This method isn’t called during sudden termination of an app. For more information about sudden termination, see the section  ProcessInfo of ProcessInfo.

## See Also

### Related Documentation

- [terminate(_:)](appkit/nsapplication/terminate(_:).md)

### Terminating Applications

- [applicationShouldTerminate(_:)](appkit/nsapplicationdelegate/applicationshouldterminate(_:).md)
- [NSApplication.TerminateReply](appkit/nsapplication/terminatereply.md)
- [applicationShouldTerminateAfterLastWindowClosed(_:)](appkit/nsapplicationdelegate/applicationshouldterminateafterlastwindowclosed(_:).md)
