---
title: "endBackgroundTask(_:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiapplication/endbackgroundtask(_:)"
---

# endBackgroundTask(_:)

Marks the end of a specific long-running background task.

## Declaration

```swift
nonisolated func endBackgroundTask(_ identifier: UIBackgroundTaskIdentifier)
```

## Parameters

- `identifier`: An identifier returned by the doc://com.apple.uikit/documentation/UIKit/UIApplication/beginBackgroundTask(expirationHandler:) method.

## Mentioned in

Extending your app’s background execution time

## Discussion

Discussion You must call this method to end a task that was started using the beginBackgroundTask(expirationHandler:) method. If you do not, the system may terminate your app. This method can be safely called on a non-main thread.

## See Also

### Managing background tasks

- [backgroundRefreshStatus](uikit/uiapplication/backgroundrefreshstatus.md)
- [UIBackgroundRefreshStatus](uikit/uibackgroundrefreshstatus.md)
- [backgroundRefreshStatusDidChangeNotification](uikit/uiapplication/backgroundrefreshstatusdidchangenotification.md)
- [beginBackgroundTask(withName:expirationHandler:)](uikit/uiapplication/beginbackgroundtask(withname:expirationhandler:).md)
- [beginBackgroundTask(expirationHandler:)](uikit/uiapplication/beginbackgroundtask(expirationhandler:).md)
- [UIBackgroundTaskIdentifier](uikit/uibackgroundtaskidentifier.md)
- [backgroundTimeRemaining](uikit/uiapplication/backgroundtimeremaining.md)
