Baruch Hashem, I'm not alone. This question is addressed by various sources, all brought in Ma Shehaya Hu Sheyihyeh Shir HaShirim II 5:3 fn. 8 by Rabbi Eliyahu Wolf from Yeshivas Ner Yisroel, Baltimore. He brings as follows:
Birkas Aharon Berachos § 268 by Rav Aharon Levine asks this question, as well on how parshas Kedoshim ends. He leaves it as צ"ע.
Death of the Erev Rav
Pardes Yosef HeChadash Balak § 212 (at the end) suggests an answer:
י"ל ע"פ מש"כ בזוה"ק פ' פנחס דהכ"ד אלף שמתו במגפה היו מערב רב שהולידו מבנות שבט שמעון
He brings from the Zohar III p. 236b that the 24,000 people who died in the plague were really the wicked erev rav. The reason the verse says they're from the tribe of Shimon is because these were offspring from the erev rav who married woman from the tribe of Shimon.
Presumably it's good that the erev rav died, as they were a negative influence. Even though these individuals were raised by Jewish mothers, it sounds like the Pardes Yosef HeChadash is suggesting that they too were wicked (presumably because of their wicked fathers, and the fact that their mothers married them proves they weren't too good either).
Chomas Anach Balak § 7 by the Chida also brings the Zohar. Not clear if he's addressing this question also, or just wants you to know about the Zohar.
Also, Sanhedrin 106a says כ"ד אלף [שהפיל מישראל], with the last words in brackets. Margaliyos HaYam Sanhedrin 106a § 14 points out that this could work with the opinion of the Zohar, that these words don't belong here.
Doesn't apply
In Ma Shehaya Hu Sheyihyeh Haftaros I p. 87 fn. 5, he brings a few other sources.
The Maharsham (in his glosses to Moed Katan 28b) asks this question. His first answer doesn't seem to be helpful here, as he is addressing parshas Kedoshim and says that verse is talking to Beis Din. His second answer sounds like he's saying that the entire Torah is good. As well, it's all letters from the name of Hashem. It sounds like according to this, he's saying this halacha doesn't apply
The Ben Ish Chai in Rav Pe'alim IV Orach Chaim § 42 answers that this rule only applied when there was the original halacha that only the first person makes a beracha on reading the Torah and the last person (Megillah 21a). The people in between shouldn't finish their aliya on a negative note. However, the person who makes the beracha, that is really how they're "ending". That's always considered ending on a positive note. Today, where everyone makes a beracha after, it always ends on a positive note. This halacha doesn't apply then.
According to these answers, I'm not sure why the Rema brought this halacha.