<!--
{
  "availability" : [
    "macOS: 15.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/presentationPreventsAppTermination(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE34presentationPreventsAppTerminationyQrSbSgF"
  },
  "title" : "presentationPreventsAppTermination(_:)"
}
-->

# presentationPreventsAppTermination(_:)

Whether a presentation prevents the app from being terminated/quit
by the system or app termination menu item.

```
nonisolated func presentationPreventsAppTermination(_ prevents: Bool?) -> some View
```

## Discussion

SwiftUI uses the buttons in a sheet’s toolbar to determine
whether a particular sheet should block termination by default.
If there is a singular toolbar item with the
[`confirmationAction`](/documentation/SwiftUI/ToolbarItemPlacement/confirmationAction) or the
[`cancellationAction`](/documentation/SwiftUI/ToolbarItemPlacement/cancellationAction) placement and no
other toolbar items, the sheet will not prevent termination by
default.

Use this modifier to specify whether a sheet should
prevent app termination. Pass `nil` to explicitly request the
automatic behavior/for the inert version of this modifier. Non-nil
values will override `nil`, and `true` takes precedence over `false`.

Use this modifier within the `content` argument to `View/sheet`

```
struct LaunchScreen: View {
  @State private var presentLogin = false
  var body: some View {
    HomeView()
      .sheet(isPresented: $presentLogin) {
        LoginView()
          // explicitly allow app termination because the
          // default behavior would resolve to `true`.
          .presentationPreventsAppTermination(false)
          .toolbar {
            ToolbarItem(placement: .cancellationAction) {
              Button("Cancel") { presentLogin = false }
            }
            ToolbarItem(placement: .confirmationAction) {
              Button("Login") {
                // Attempt login...
                presentLogin = false
              }
            }
          }
        }
    }
}
```

---

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)