Sorry, forget about the last versions, I mistook where the WM_DESTROY is coming from. It's not coming from imm32 DllMain. That means it simply ignores the deinitialization... Sorry about that.
This is a new approach that should also fix the issue, this time preventing the loader lock that causes the issue in the first place. Not 100% sure if that's the right way to go about it, though.