<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/DispatchIO/close(flags:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "s:So14OS_dispatch_ioC8DispatchE5close5flagsyAbCE10CloseFlagsV_tF"
  },
  "title" : "close(flags:)"
}
-->

# close(flags:)

Closes the channel to new read and write operations.

```
func close(flags: DispatchIO.CloseFlags = [])
```

## Parameters

`flags`

The options to use when closing the channel. For a list of possible values, see [`DispatchIO.CloseFlags`](/documentation/Dispatch/DispatchIO/CloseFlags).

## Discussion

After calling this method, do not schedule any more read or write operations on the channel. Doing so causes an error to be sent to your handler.

If the [`stop`](/documentation/Dispatch/DispatchIO/CloseFlags/stop) option is specified in the flags parameter, the system attempts to interrupt any outstanding read and write operations on the I/O channel. If you specify this flag, the corresponding handlers may be invoked with partial results. In addition, the final invocation of the handler is passed the `POSIXErrorCode.ECANCELED` error code to indicate that the operation was interrupted. If you do not specify the [`stop`](/documentation/Dispatch/DispatchIO/CloseFlags/stop) flag, read and write operations on the channel run to completion as normal.

---

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)