Moved check for existence of active window inside cycle_active_window().