# How to leave the session from the program

**URL:** <https://devforum.zoom.us/t/how-to-leave-the-session-from-the-program/103370>\
**Category:** UI ToolKit\
**Created:** [February 7, 2024, 8:18am UTC](https://devforum.zoom.us/t/how-to-leave-the-session-from-the-program/103370 "2024-02-07T08:18:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmiyaji](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cmiyaji/32/55574_2.png) [@cmiyaji](https://devforum.zoom.us/u/cmiyaji)\
**Post date:** [February 7, 2024, 8:18am UTC](https://devforum.zoom.us/t/how-to-leave-the-session-from-the-program/103370/1 "2024-02-07T08:18:37Z")

</div>

When UI Toolkit video session start, I can only leave this session by clicking the red telephone button on right top. How can I leave session from the program.  
I tried  
zoom.onSessionLeave()  
but the session does not leaved.  
Is there any proper method to leave on Swift?

---

<div class="post-metadata">

**Author:** ![rehema.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rehema.zoom/32/40323_2.png) [@rehema.zoom](https://devforum.zoom.us/u/rehema.zoom)\
**Post date:** [February 13, 2024, 3:07pm UTC](https://devforum.zoom.us/t/how-to-leave-the-session-from-the-program/103370/2 "2024-02-13T15:07:20Z")

</div>

Hi @cmiyaji ,

With the UI Toolkit, you can programmatically leave a session by calling `uitoolkit.closeSession(sessionContainer)`. See our [documentation](https://developers.zoom.us/docs/video-sdk/web/ui-toolkit/#leave-or-end-session) for more information, and please let me know if this answers your question!

Thanks,  
Rehema

---

<div class="post-metadata">

**Author:** ![cmiyaji](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cmiyaji/32/55574_2.png) [@cmiyaji](https://devforum.zoom.us/u/cmiyaji)\
**Post date:** [February 13, 2024, 5:14pm UTC](https://devforum.zoom.us/t/how-to-leave-the-session-from-the-program/103370/3 "2024-02-13T17:14:27Z")

</div>

Thank Rehma for answering my question.  
I use Swift, and use GIT ui toolkit sample to test. It opens zoom session  
let vc = UIToolkitVC(sessionContext: SessionContext(jwt: jwt, sessionName: sessionName, username: username))  
But this vc does not have closeSession () method.  
where I’ll find closeSeesion() method?

 ![スクリーンショット 2024-02-14 2.12.17](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/2/a/2ac9fdacab1199571725b891c410eb33655fc5bf.jpeg)

---

<div class="post-metadata">

**Author:** ![cmiyaji](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cmiyaji/32/55574_2.png) [@cmiyaji](https://devforum.zoom.us/u/cmiyaji)\
**Post date:** [February 17, 2024, 3:44am UTC](https://devforum.zoom.us/t/how-to-leave-the-session-from-the-program/103370/4 "2024-02-17T03:44:30Z")

</div>

Dear Rehema

I found the method eventually, dismiss(…) is the method to leave the session.  
open the zoom,  
`self.zoom = UIToolkitVC(sessionContext: SessionContext(jwt: info.jwt, sessionName: info.sessionName, username: info.userIdentity))`  
and close it by  
`self.zoom.dismiss(animated: true)`  
close the session.

This is what I want for closing the session, but I have a bit different session control to pause it. I’ll write on different topic, I’m glad that you’ll show the solution.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [February 10, 2025, 7:09pm UTC](https://devforum.zoom.us/t/how-to-leave-the-session-from-the-program/103370/5 "2025-02-10T19:09:26Z")

</div>

Glad to hear you found the function to close the session @cmiyaji !
