And since Zimri did that deed, what is written? "Then he went after the man of Israel into the chamber" (Numbers 25:8). And where was Phinehas speaking before Moses? In order to fulfill what is said, "and there is no dominion on the day of death" (Ecclesiastes 8:8). And "death" is nothing but an expression of lowering: the deliverance was given to Phinehas, and he lowered Moses.
Phinehas Rises Before Moses as Death Approaches
Midrash Tanchuma Buber, Vayechi 3:2
וכיון שעשה זמרי אותו מעשה מה כתיב, ויבא אחר איש ישראל אל הקב"ה וגו' (במדבר כה ח) ואיכן היה פנחס מדבר לפני משה, לקיים מה שנאמר ואין שלטיון ביום המות, [ואין מות] אלא לשון השפלה ניתנה הישועה לפנחס והשפיל את משה.