---
title: "endSheet(_:returnCode:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsapplication/endsheet(_:returncode:)"
---

# endSheet(_:returnCode:)

Ends a document modal session by specifying the sheet window.

## Declaration

```swift
func endSheet(_ sheet: NSWindow, returnCode: Int)
```

## Parameters

- `sheet`: The sheet whose modal session you want to end.
- `returnCode`: The return code to send to the delegate. You can use one of the return codes defined in doc://com.apple.appkit/documentation/AppKit/NSApplication/ModalResponse or a custom value that you define.

## See Also

### Methods

- [activate(ignoringOtherApps:)](appkit/nsapplication/activate(ignoringotherapps:).md)
- [endModalSession(_:)](appkit/nsapplication/endmodalsession(_:).md)
- [beginSheet(_:modalFor:modalDelegate:didEnd:contextInfo:)](appkit/nsapplication/beginsheet(_:modalfor:modaldelegate:didend:contextinfo:).md)
- [endSheet(_:)](appkit/nsapplication/endsheet(_:).md)
