---
title: "dialogPreventsAppTermination(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/dialogpreventsapptermination(_:)"
---

# dialogPreventsAppTermination(_:)

Whether the alert or confirmation dialog prevents the app from being quit/terminated by the system or app termination menu item.

## Declaration

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

```

## Discussion

Discussion SwiftUI uses the actions passed to the above dialogs to determine whether the dialog should block app termination by default when presented. If all of the following are satisfied, the dialog will not block app quit: There is only a single button and its role is not destructive The dialogSeverity(_:) is not `DialogSeverity/critical`` There are no TextFields Use this modifier after a View/alert or View/confirmationDialog to specify whether the dialog should prevent app termination. Pass nil to explicitly request the automatic behavior/for the inert version of this modifier. struct ConfirmLogoutView: View {   @State private var isConfirming = false

var body: some View {     Button("Logout") { isConfirming = true }       .confirmationDialog(         Text("Logout?"),           isPresented: $isConfirming         ) {           Button("Yes") {             // Handle logout action.           }         }         .dialogPreventsAppTermination(false)     } }

## See Also

### Configuring a dialog

- [dialogIcon(_:)](swiftui/view/dialogicon(_:).md)
- [dialogIcon(_:)](swiftui/scene/dialogicon(_:).md)
- [dialogSeverity(_:)](swiftui/view/dialogseverity(_:).md)
- [dialogSeverity(_:)](swiftui/scene/dialogseverity(_:).md)
- [dialogSuppressionToggle(isSuppressed:)](swiftui/view/dialogsuppressiontoggle(issuppressed:).md)
- [dialogSuppressionToggle(isSuppressed:)](swiftui/scene/dialogsuppressiontoggle(issuppressed:).md)
- [dialogSuppressionToggle(_:isSuppressed:)](swiftui/view/dialogsuppressiontoggle(_:issuppressed:).md)
- [dialogSuppressionToggle(_:isSuppressed:)](swiftui/scene/dialogsuppressiontoggle(_:issuppressed:).md)
