<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIApplication/endBackgroundTask(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIApplication(im)endBackgroundTask:"
  },
  "title" : "endBackgroundTask(_:)"
}
-->

# endBackgroundTask(_:)

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

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

## Parameters

`identifier`

An identifier returned by the [`beginBackgroundTask(expirationHandler:)`](/documentation/UIKit/UIApplication/beginBackgroundTask(expirationHandler:)) method.

## Discussion

You must call this method to end a task that was started using the [`beginBackgroundTask(expirationHandler:)`](/documentation/UIKit/UIApplication/beginBackgroundTask(expirationHandler:)) method. If you do not, the system may terminate your app.

This method can be safely called on a non-main thread.

---

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)