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. The same visible resolution label can therefore use different output modes.
A temporary mode switch should end with a working image. If the display stays black, investigate it separately. See Refresh Rate, Color Mode and display connection management.