# What order of release is required, to safely fully exit a module of a plugin?

**URL:** <https://forums.steinberg.net/t/what-order-of-release-is-required-to-safely-fully-exit-a-module-of-a-plugin/984051>\
**Category:** VST 3 SDK\
**Created:** [April 13, 2025, 4:19am UTC](https://forums.steinberg.net/t/what-order-of-release-is-required-to-safely-fully-exit-a-module-of-a-plugin/984051 "2025-04-13T04:19:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SunshineDreaming](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SunshineDreaming](https://forums.steinberg.net/u/SunshineDreaming)\
**Post date:** [April 13, 2025, 4:19am UTC](https://forums.steinberg.net/t/what-order-of-release-is-required-to-safely-fully-exit-a-module-of-a-plugin/984051/1 "2025-04-13T04:19:10Z")

</div>

My [previous question](https://forums.steinberg.net/t/how-safely-exit-any-worker-thread-on-removing-a-vst3-plugin-on-windows/901112) was answered related to the directly module exit of a plugin.  
But what about the order of releasing the objects? I found, that some plugins seem to unexpectedly terminate, if the order is done differently. Is there a mandatory / recommened order ?

For a lot of plugins this order seems to work, but is it correct?

```auto
// if the plugview window is still open:
windowController->closePlugView(); // Steinberg::Vst::EditorHost::WindowController

App_editController->setComponentHandler(NULL); // Steinberg::Vst::IEditController*
vst3Processor->terminate(); // Steinberg::Vst::AudioClient*
_plugProvider = NULL; // Steinberg::IPtr<Steinberg::Vst::PlugProvider>
App_editController->release();
component->release(); // Steinberg::Vst::IComponent*

// optional ExitDll + FreeLibrary :
module = NULL; // VST3::Hosting::Win32Module::Ptr

SAFE_DELETE(m_ComponentHandlerPtr); // ComponentHandler*

App_editController = NULL;
component = NULL; // I use it as a pure pointer, so not DTOR called here

```

Should the order be changed? Its unclear for me, whether the plugins, which are still not closing properly, have internally a failure, or whether its caused by the order of releasing these objects…  
Often an unexpected-termination occurs when calling FreeLibrary.  
For most what I’ve experienced, the unexpected-termination-problem only occurs during unloading, if an edit controller plugview window was shown. When only opening the component without a plugview, on unloading module the termination does not occur in that faulty way.

Thank you!

My System OS: Windows 10 PRO 22H2

---

<div class="post-metadata">

**Author:** ![SunshineDreaming](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SunshineDreaming](https://forums.steinberg.net/u/SunshineDreaming)\
**Post date:** [April 19, 2025, 4:34am UTC](https://forums.steinberg.net/t/what-order-of-release-is-required-to-safely-fully-exit-a-module-of-a-plugin/984051/2 "2025-04-19T04:34:05Z")

</div>

After reviewing closePlugView(), I found an issue with releasing the plugview in my code.  
Now all the previously unexpectedly-terminating plugins seem to unload correctly!
