---
title: "stop(_:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkhealthstore/stop(_:)"
---

# stop(_:)

Stops a long-running query.

## Declaration

```swift
func stop(_ query: HKQuery)
```

## Parameters

- `query`: Either an doc://com.apple.healthkit/documentation/HealthKit/HKObserverQuery instance or an doc://com.apple.healthkit/documentation/HealthKit/HKStatisticsCollectionQuery instance.

## Mentioned in

Executing Observer Queries Reading route data

## Discussion

Discussion Use this method on long-running queries only. Most queries automatically stop after they have gathered the requested data. Long-running queries continue to operate on a background thread, watching the HealthKit store for updates. You can cancel these queries by using this method.

## See Also

### Querying HealthKit data

- [execute(_:)](healthkit/hkhealthstore/execute(_:).md)
