From: Alex Ionescu
I have some loader fixes which handle serialization and fix similar race conditions. If you look on my blog, you can see the timeframe for when I plan to commit them... if you're not going to submit the shutdown code until then, then you can probably consider this issue fixed and work on other problems. Of course, if you prefer, you can write a quick hack if you need this working now :)
I had promised TwoTailedFox to commit my shutdown work this week. The race condition only results in a usermode exception, terminating the thread. Since the process was going to exit anyway, it's not really a big deal and doesn't block my progress. The reason I brought it up was that race conditions like this are generally hard to reproduce, so when I do hit a reproducible case I tend to start fixing it before moving on. So, in this case I'll continue on the shutdown stuff and commit it this week, leaving the kernel32 issue to you.
GvG