Q. (See question 1761 above). How come some Parshios (like Kedoshim, Balak and others) do end with a wrong done?
A. Mishna Berura (138: 1) rules that the wrong done to an evil person or a non believer does not count. Others maintain that the need to finish with a proper ending, applies basically to the middle of the parsha and not to the end, as those endings were established by Moshe Rabbenu himself.
Horav Shlomo Miller Shlit'a added that the last posuk of Balak (25: 9) reads; "The dead in the plague were..." meaning that they were destined to die before and already considered so.
Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit’a