Move windows between displays without dragging
If you want a trick, you could briefly unplug the HDMI cable from the iMac. That should signal Mac OS that there is only one display and it will move all windows to the only remaining display.