Unkillable app in NtGdi DestroyAllocation2 after d3d11.dll Flush() when running for multiple days

Hello, we have an issue with a C++ d3d11 software we develop. After running for multiple days, usually over 40 hours, we get a hang in win32u.dll!NtGdiDdDDIDestroyAllocation2() after we try to close the application. The process becomes stuck and impossible to kill via any means. We tried pskill, terminate, end process with task manager and other methods. No noticeable memory or graphics leak present. A reboot must be done and we often cannot do this in our production. This does not happen after one day of running. Let me know if I should post this elsewhere.

We’ve tested various Nvidia drivers and Windows OS. It seems to happen since we started using windows 11 even with fresh installs.

We reproduced this with latest version of the following:
Windows 11 Pro 23H2, Build 22634.3447
Nvidia Quadro Driver 546.01
PC is a HP Z4 G4 with Quadro RTX 4000 GPU, Xeon W-2445, 64GB ECC Ram (all HP).

Here’s the stack trace:

win32u.dll!NtGdiDdDDIDestroyAllocation2() Unknown
d3d11.dll!CallAndLogImpl<long (*)(struct _D3DKMT_DESTROYALLOCATION2 const *),struct _D3DKMT_DESTROYALLOCATION2 >(long ()(struct _D3DKMT_DESTROYALLOCATION2 const *),char const *,struct _D3DKMT_DESTROYALLOCATION2 *) Unknown
d3d11.dll!NDXGI::CDevice::Deallocate2CB() Unknown
nvwgf2umx.dll!00007ffd022a24f7() Unknown
nvwgf2umx.dll!00007ffd03b713c9() Unknown
nvwgf2umx.dll!00007ffd022d1edf() Unknown
nvwgf2umx.dll!00007ffd022d6682() Unknown
nvwgf2umx.dll!00007ffd02327013() Unknown
nvwgf2umx.dll!00007ffd0365850a() Unknown
nvwgf2umx.dll!00007ffd036ba93c() Unknown
d3d11.dll!NDXGI::CDevice::Flush() Unknown
d3d11.dll!NDXGI::CDevice::FlushAndEnqueueSetEvent() Unknown
d3d11.dll!CContext::TID3D11DeviceContext_Flush_AppEntered() Unknown