That’s not an accurate statement of the rule. There are several things which “immediately end the game” – checkmate, resignation, stalemate, loss on time (if valid). It is the first one to occur that governs. You cannot resign a game (or agree to a draw) after having given checkmate. The grey area arises whan two (or more) of these has taken place, and it cannot be readily detemined which happened first.