Markus had it right (probably remembers my explanation from before on the forum
If the spear user moves more than their Reach from an opponent during a single action, then they have left melee and any opponent they were adjacent to in that round gets a free attack.
Remember a character's actions during a round are pretty much simultaneous, so effects are based off that. The system allows for the freedom to break down those "individual" actions as the player wishes (such as move then attack, attack then move, move a bit then attack then move a bit more, and so on...) but that's because while it may change a situational effect, it (typically) does not change the effect of the actual action.
Wow, that feels unclear. Hope it makes sense.
Ultimately, "leaving melee" can simply be defined as, "If at any point during your chosen movement for the round
neither you nor your opponent would be capable of making a melee attack on each other."
Congratulations, you just left melee.