Fix. Cleanup resource only if DLL unloaded dynamically.