"and when the sun sets": The (non-) setting of the sun prevents him from entering the camp.

(Devarim 23:13) "And a yad shall there be for you outside the camp": "yad" signifies a place, as it is written (I Samuel 15:12) "and he has set himself up a yad," and (Bamidbar 2:17) "every man in his yad by their flags."