---
title: os_workgroup_leave
framework: os
role: symbol
role_heading: Function
path: os/os_workgroup_leave
---

# os_workgroup_leave

Removes the current thread from the workgroup it previously joined.

## Declaration

```occ
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

Discussion Always call this function using the same os_workgroup_t and 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.

## See Also

### Thread Attachment

- [os_workgroup_join](os/os_workgroup_join.md)
- [os_workgroup_join_token_t](os/os_workgroup_join_token_t.md)
