---
title: "endCollection(withEnd:completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkworkoutbuilder/endcollection(withend:completion:)"
---

# endCollection(withEnd:completion:)

Stops the collection of data, sets the workout’s end date, and deactivates the workout builder.

## Declaration

```swift
func endCollection(withEnd endDate: Date, completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```swift
func endCollection(at endDate: Date) async throws
```

## Mentioned in

Running workout sessions

## See Also

### Ending the workout

- [endDate](healthkit/hkworkoutbuilder/enddate.md)
- [finishWorkout(completion:)](healthkit/hkworkoutbuilder/finishworkout(completion:).md)
- [discardWorkout()](healthkit/hkworkoutbuilder/discardworkout().md)
