Really short description how to setup OBS with replay buffer for this:
If you start OBS for the 1st time after installation, the auto configuration wizard appears. Let it optimize for recording, use as Base resolution the monitor resolution, either 30 or 60 fps. If you clicked it away, restart it from Tools->Auto Configuration Wizard.
Then add a source with type "Display Capture".
Then go to Settings->Output and in the Recording section, activate the replay buffer.
In the replay buffer configuration below, enter 300 sec and as much RAM as you can spare for temporary video buffer, should be not lower than 512, better 2048 MB.
Now click on the "Start replay buffer" button and minimize OBs.
After a minute or so, test it. Restore OBS and click on the small button next to the Replay buffer button with the download icon. OBS will write whatever it recorded in the last minute to disk and continue recording. If your bug appears, do this again and save the replay buffer. There is no permanent recording to disk unless you explicitly save the replay buffer, so no unnecessary disk usage.
You find your recording by selecting File->Show Recordings.
You can also set a hotkey to save the replay buffer. Look in settings->Hotkeys->Replay buffer->Save replay (not "Start Replay Buffer/Stop Replay buffer", these start or stop buffering in general, but don't save any data.