---
title: "close(completionHandler:)"
framework: accessoryaccess
role: symbol
role_heading: Instance Method
path: "accessoryaccess/aausbaccessory/close(completionhandler:)"
---

# close(completionHandler:)

Closes all connections to the USB accessory for this process.

## Declaration

```swift
func close(completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func close() async throws
```

## Parameters

- `completionHandler`: A block the framework calls after the client has successfully closed the USB accessory. The error parameter the framework passes to the block is nil if the operation was successful. The framework invokes the block on an arbitrary thread.

## Discussion

Discussion warning: Closing an accessory by calling the destroy() method on an IOUSBHostDevice is a blocking operation. Such an operation causes a deadlock, if you call it from a completion handler. This operation closes the USB accessory, that the app previously opened through open(serviceQueue:completionHandler:). Once this operation completes, the framework invalidates any IOUSBHostDevice object it previously returned and you can’t use it for USB transfers. This operation has the same effect as calling the destroy method on IOUSBHostDevice. Once the app closes the accessory, the app can re-open the accessory using this process or any other worker process of this client application for exclusive access using open(serviceQueue:completionHandler:).

## See Also

### Managing a USB accessory

- [open(serviceQueue:completionHandler:)](accessoryaccess/aausbaccessory/open(servicequeue:completionhandler:).md)
