Why does my external monitor briefly go black when I disconnect the built-in display?
A brief blackout can occur when macOS switches the external display's output mode for the new display arrangement. The monitor may need to resynchronize even though you disconnected only the built-in display.
Compare the external display's Refresh Rate and, where available, Color Mode before and after the change. A different refresh rate or connection format can explain the interruption. On Apple silicon, Color Mode shows details such as bit depth, encoding, range and HDR state when connection information is available.
If avoiding the interruption matters, try an output mode that is available in both arrangements, keeping its refresh rate and color format the same. Changing the scaled desktop size alone does not necessarily change the physical signal timing. Matching the visible resolution label is therefore not enough to establish that the two output modes are identical.
This explains a short interruption followed by a working image. A display that stays black needs separate investigation. Do not assume it is the same temporary mode switch. See Refresh Rate, Color Mode and display connection management.