Can I avoid windows snapping to main screen when I briefly lose my second screen?

Stay should solve this for you. It's not free, but it's not expensive either.