This is all based on a vague memory of a fever dream from years ago but…
*In windows you have two options for window placment: keep windows on active screens or don’t do anything. *You can move windows around with shift+win+arrow keys. *AutoIT and Auto Hotkey programs can identify individual windows. I would bet that they can also read if a monitor is on or off.
Write a script that check whether a monitor is on or off then move the identified windows. There are tons of tutorials for both AutoIT and Auto Hotkey out there and I’m sure someone has already implemented exactly what you are looking for.