Fixed unloading of plugins with shared pointers