Weird behavior when using .pyd (cython module)

I was writing an optimized mouse look script in cython and after compiling it on windows 7 (64 bits) I got this weird behavior:

The blend could only be executed 1 time, after it crashed (only if the .pyd function was called).
After further investigation, I found that the loaded .pyd(s) were not “unloaded” when the game engine exit.

After hours of testing, I found that blender crash because executing the pyd a second time seems to corrumpt the pyd (only in memory), raising a “System Error : Bad argument for internal function”.

After further debugging, I found that the error was (maybe partially) caused by the corruption of the names that were imported in the pyd. In my case, “getCurrentController” .
Which explains why my cython test did not crash after multiple execution (it didn’t imported any names).

I assume that this is caused because the loaded .pyd files are not unloaded when the game engine exit.

Here’s my blend (with everything needed), the pyd is alread compiled for windows x64. Otherwise you will have to compile it yourself.:

Any help with this problem would be really welcome. (82.7 KB)