I observed that this problem never happens if a window is maximized or "half-maximized" (dragged to left or right edge of the screen). Maximized windows get restored to the display they were on.