Sleep window switch logic