Steps to replicate: use DP as main monitor + HDMI to audioreceiver that goes to your second monitor:
Monitor 1 <- GPU
Monitor 2 <- Audio Receiver <- GPU
Unplug monitor 2 from audio receiver and factorio will hang on exit.

I'm not sure if it's worth fixing or can reveal underlying problem of some sorts or if it's just my specific case but at least you'll know.