I'm fairly certain it's not a hardware problem since the mouse still works and switching to the text console and killing XOrg works. I only ever had this happen with factorio running at an accelerated speed. It only happened after I updated from 1.1.38 but that might just be because I didn't use the editor to accelerate time. I think it has never happened with factorio in the foreground but I'm not 100% certain.
After killing XOrg factorio either dies on it's own (previous) or I have to kill it (current). First time factorio survived killing XOrg, all other times it died on it's own.
0.000 2021-10-27 00:47:01; Factorio 1.1.42 (build 59009, linux64, full)
0.032 Operating system: Linux (Debian 10)
0.032 Program arguments: "bin/x64/factorio"
0.032 Read data path: /home/mrvn/factorio/factorio-1.1.38/data
0.032 Write data path: /home/mrvn/factorio/factorio-1.1.38 [540797/1558132MB]
0.032 Binaries path: /home/mrvn/factorio/factorio-1.1.38/bin
0.042 System info: [CPU: AMD Ryzen 5 2400G with Radeon Vega Graphics, 8 cores, RAM: 63331 MB]
0.042 Environment: DISPLAY=:0.0 WAYLAND_DISPLAY=<unset> DESKTOP_SESSION=lightdm-xsession XDG_SESSION_DESKTOP=lightdm-xsession XDG_CURRENT_DESKTOP=XFCE __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> __GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
0.042 Display options: [FullScreen: 1] [VSync: 1] [UIScale: automatic (100.0%)] [Native DPI: 1] [Screen: 255] [Special: lmw] [Lang: en]
0.149 Available displays: 1
0.149 [0]: PA248 26" - {[0,0], 1920x1200, SDL_PIXELFORMAT_RGB888, 60Hz}
0.186 Initialised OpenGL:[0] AMD RAVEN (DRM 3.37.0, 5.7.0-0.bpo.2-amd64, LLVM 7.0.1); driver: 4.5 (Core Profile) Mesa 18.3.6
0.186 [Extensions] s3tc:yes; KHR_debug:yes; ARB_clear_texture:yes, ARB_copy_image:yes
0.186 [Version] 4.5
0.186 Graphics settings preset: medium-with-low-vram
0.186 Dedicated video memory size 1024 MB
0.202 Graphics options: [Graphics quality: normal] [Video memory usage: high] [DXT: low-quality] [Color: 32bit]
0.202 [Max threads (load/render): 32/8] [Max texture size: 4096] [Tex.Stream.: 1] [Rotation quality: low] [Other: sTDCwt] [B:0,C:0,S:100]
0.466 [Audio] Backend:default; Depth:16, Channel:2, Frequency:44100; MixerQuality:linear