<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/os_workgroup_leave",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "c:@F@os_workgroup_leave"
  },
  "title" : "os_workgroup_leave"
}
-->

# os_workgroup_leave

Removes the current thread from the workgroup it previously joined.

```
extern void os_workgroup_leave(os_workgroup_t wg, os_workgroup_join_token_t token);
```

## Parameters

`wg`

The workgroup to leave. This workgroup must be the same workgroup that the thread previously joined. If it isn’t, this function aborts the process.

`token`

The token you received when the thread joined the workgroup. If the data in the token is invalid, if the token belongs to a different thread, or if the workgroup in the `wg` parameter doesn’t match the information in the token, this function aborts the process.

## Discussion

Always call this function using the same [`os_workgroup_t`](/documentation/os/os_workgroup_t) and [`os_workgroup_join_token_t`](/documentation/os/os_workgroup_join_token_t) structures you used at join time. If the workgroup or token information doesn’t match, this function aborts the current process. You may call this function safely from a real-time thread of your app.

> Important:
> Always remove a thread from its workgroup before the thread exits. If a thread is still joined to a workgroup when it terminates, the system aborts the current process.

---

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)