Fix issue with shared library unloading linux

Still have issue with windows, need to debug issue