I think I found a fix. I disabled Optimization for Windowed Games and I disabled Hardware Accelerated GPU Scheduling and now it works as it should