NixOS with eGPU - Hot unplugging?

Hi all!

I run nixos on my laptop, and I use an AMD eGPU in a Thunderbolt enclosure. It works well for providing the power I need for gaming, but the screen freezes hard and I have to hold the power button for 10 seconds in order to power off whenever I unplug. I’ve heard that this is called a kernel panic, and it’s happening here because the system is trying to use an absent gpu to render the display.

Would it be possible to force my computer to use the integrated graphics for all applications by default, and then only use the eGPU to run certain applications, and would that allow hot-unplugging the eGPU?

EDIT: So if I disable the external monitors connected thru the eGPU in display manager, I can hot-remove just fine. Unfortunately, I was also hoping for the eGPU to function as a multi-monitor dock.

Ideal solution: Computer detects when the eGPU is unplugged and, before panicking, disables all displays connected thru it.
Adequate solution: When I unplug, I can first close the lid or use a keyboard shortcut to quickly disable the external monitors.

EDIT 2: Adequate solution achieved: In KDE Plasma, Power Settings → On AC Power → When Laptop Lid Closed: Turn off Screen; Even when an external monitor is connected.

Have you heard of any Linux-based setup with that line of GPUs that works with hot-unplugging for anyone? Because in some conversations about e.g. Rust-in-Linux-kernel etc. I have read that for many GPUs hot unplugging generally doesn’t work.

I’ve seen a couple places say support was added circa 2021, and I’ve done a couple experiments and on rare occasions I don’t get a freeze (possibly because on those occasions I somehow don’t have any applications running on the egpu?) so I figured it miiight be possible.