panda quit when calling destroywindow method from directx

In order to try to better understand and debug the problem, I used the c++ panda hello world, and call my method inside.
I finally manage to find the cause of the problem, but not really the “Why”.
In my library, I have an object BasicD3D. This object creates an hWnd with CreateWindow.
In his destructor, he calls DestroyWindow(hwnd) and here is the problem. It also kills panda window.
I didn’t find yet the reason, so if anybody has a clue.