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

# stopModal()

Stops a modal event loop.

```
func stopModal()
```

## Discussion

This method should always be paired with a previous invocation of [`runModal(for:)`](/documentation/AppKit/NSApplication/runModal(for:)) or [`beginModalSession(for:)`](/documentation/AppKit/NSApplication/beginModalSession(for:)). When [`runModal(for:)`](/documentation/AppKit/NSApplication/runModal(for:)) is stopped with this method, it returns `NSModalResponseStop`. In macOS 10.9 and later, you can use this method to stop a [`runModal(for:)`](/documentation/AppKit/NSApplication/runModal(for:)) loop outside of an event callback, such as from within a method repeatedly invoked by an <doc://com.apple.documentation/documentation/Foundation/Timer> object or a method running in a different thread.

---

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)