# What is the proper sequence to shut down FMOD?

**URL:** https://qa.fmod.com/t/what-is-the-proper-sequence-to-shut-down-fmod/21007
**Category:** FMOD Studio
**Created:** [December 19, 2023, 3:54pm UTC](https://qa.fmod.com/t/what-is-the-proper-sequence-to-shut-down-fmod/21007 "2023-12-19T15:54:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mrhelmut](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mrhelmut](https://qa.fmod.com/u/mrhelmut)
#### Post date: [December 19, 2023, 3:54pm UTC](https://qa.fmod.com/t/what-is-the-proper-sequence-to-shut-down-fmod/21007/1 "2023-12-19T15:54:41Z")

</div>

Hello there,

Following a user issue leading to the application hanging forever on their machine, we narrowed this problem down to when the application is closing and calls `Studio::System::flushCommands()` (which blocks forever).

Our shut down sequence is:

- `Studio::System::unloadAll()`
- `Studio::System::flushCommands()`
- `Studio::System::release()`

This made me wonder what is the expected sequence to shut down FMOD. Some exemples call `Studio::System::unloadAll()` and `Studio::System::release()` and that’s it.  
Other exemples unload each banks individually, and some examples call `Studio::System::flushCommands()` before `Studio::System::release()` (to make sure that the banks are unloaded, I assume?) but some don’t.

Is `Studio::System::flushCommands()` even needed? Does `Studio::System::release()` calls it internally and/or wait for the banks to actually be unloaded?

And is `Studio::System::unloadAll()` required? There is at least one exemple that loads a bank and just call `Studio::System::release()` without explicitly unloading anything.

Thanks for any clarification.

Cheers!

(Running on FMOD 2.02.11 and the freeze also happened on earlier versions.)

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [December 21, 2023, 12:54am UTC](https://qa.fmod.com/t/what-is-the-proper-sequence-to-shut-down-fmod/21007/2 "2023-12-21T00:54:23Z")

</div>

Hi,

To `Shut Down` the FMOD System you can just call `Studio::System::release()`. You can read more about it here: [FMOD Engine | White Papers - Shut Down](https://fmod.com/docs/2.02/api/white-papers-getting-started.html#shut-down). The release function takes care of all the unloading for you.

> [@mrhelmut](#):
>
> to make sure that the banks are unloaded, I assume?

More information about `flushCommands()` can be found here: [FMOD Engine | Core API Reference - System](https://fmod.com/docs/2.02/api/studio-api-system.html#studio_system_flushcommands). In summary, this will block the calling thread until all pending commands have been executed, this is useful if you want to control when a command is called. Yes, it ensures that all commands have been completed before calling release.

> [@mrhelmut](#):
>
> Is `Studio::System::flushCommands()` even needed? Does `Studio::System::release()` calls it internally and/or wait for the banks to actually be unloaded?

No, the `release()` function will take care of all of this for you.

> [@mrhelmut](#):
>
> And is `Studio::System::unloadAll()` required?

It is not required when shutting down the FMOD system, the example using this function was a display of all the different methods for loading banks so it was added as a safeguard but not necessary if you are using the same method for all your banks.

Hope this helps!

---

<div class="post-metadata">

### Author: ![mrhelmut](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mrhelmut](https://qa.fmod.com/u/mrhelmut)
#### Post date: [December 21, 2023, 8:28am UTC](https://qa.fmod.com/t/what-is-the-proper-sequence-to-shut-down-fmod/21007/3 "2023-12-21T08:28:47Z")

</div>

Crystal clear. Thank you, Connor.
