Disable the Game Bar and Background Recording
Game Bar is a feature available on both Windows 10 and 11. It allows you to record game clips, take screenshots, and even stream your gameplay. However, using this feature will lead to lower game performance. Therefore, you should turn it off except in a few cases when needed for work.
To turn off Game Bar, you need: Open Settings > Gaming > Xbox Game Bar. On Windows 10, turn off the Enable Xbox Game Bar... slider at the top to prevent it from running. On Windows 11, turn off the Open Xbox Game Bar...
Next, you should switch to the Capture tab > on Windows 10 turn off the Record in the background while I'm playing a game toggle, and on Windows 11 turn off the Record what happened toggle.