I have been told that the G-sync setting on my graphics card could potentially be to blame for all my trouble. It has been set to only work on Fullscreen applications. I have now turned it off completely, and it seems like the problem does not show up anymore. I'll wait a few more days, and then I'll see what difference turning it on for both fullscreen and windowed applications will do.