An entity is no longer mastered when it dies, when the caster dies, or when the entity goes out of range. Using Order Elemental / Order Entity will also end mastery. And I don't see anything to prevent Dispelling the mastery spell.
But I do think it's the intent that you can keep 1-2 entities around indefinitely (not 3 with Entity Mastery, the spell explicitly says no more than 2). That's in line with what you can do with Mastered undead, which also have a range limit but don't have the annoying habit of returning to another plane.
From Essence Companion, Elemental Summons
5. Summon Elemental Servant—Allows caster to summon an Elemental Servant. The caster must be in range of necessary materials for the elemental type he is attempting to summon (campfire for Fire Servant, ice for Cold Servant, etc.). The Elemental will gradually manifest itself over the course of 2 rounds.
6. Master Elemental Servant—As Control Elemental Servant, except caster need not concentrate to control elemental. The elemental will remain and obey the caster until the caster is killed, the elemental is outside the range limit, or the elemental is killed. If the elemental is ever freed from this bond, it will either return to its normal plane of existence or attack the sum- moner (equal chance of either).
A maximum of three Elemental Servants can be mastered by any one being at one time.
We play it that you can have them indefinitely but that makes mages with access to the spells, very potent sice they essentially have three elemental ball attacks available within 30' at all times.