The adventure is explicit about one and vague about the other
The description of
Area 12 (Smelter Cavern)
says that: "Eight of the fallen dwarf warriors" there...
...are Zombies. "They rise and pursue any living creatures that enter the room, but they do not pursue creatures outside this area for more than 1 round."
Thus we know exactly how far they will go in their pursuit of characters, and when they will return - at least under their current instructions. But we are also told that
"Mormesk [the wraith in Area 14]
leads the undead that haunt Wave Echo Cave."
and further that:
"so far, the creature has easily handled the assaults of
Mormesk’s zombies and ghouls
while seeing nothing strange about undead roaming the mine."
It is clear that this individual is the one directing the lesser undead. It is thus possible that this leader will change the orders under which they operate in order to react to the party's attempts to reach
the Forge of Spells.
On the other hand,
The flameskull
is described as having been
a servant of the human wizards allied with the Phandelver dwarves and gnomes, and it continues to act on ancient instructions to prevent intruders from passing through.
From the lore of this creature, we know that it:
carries out the directives given to it when it was created, and it interprets those commands to the letter. [It's] master must craft its instructions with care to ensure that the creature carries out its tasks properly.
We thus know that this creature was given careful, precise instructions, and that these instructions predated the fall of the Mine. It will be the DM's job to determine what these instructions were, and how to apply them to the actions of the PCs.
Personally, it seems reasonable to me that:
If the pre-fall purpose of the flameskull was to guard access to the Forge of Spells, it would not back off simply because the PC's left its room. Rather, it would follow them, attacking and shouting 'Intruders!' all the while, expecting to raise an alarm and for the dwarf, wizard, and gnome defenders of the mine to show up. It might stop attacking when they left the area of the Forge and Smelter, but it would continue to shout for guards and follow them at least until the point when it needed to return to guard the Forge (so that it couldn't be led away as a diversion). Now, there might at some point have been guests in the Mine who were over-curious or wandered into the area of the Forge. I would think that the flameskull could be told to cease attacking, and cease raising the alarm, by anyone it recognized as one of its wizard creators. And that might even include Mormensk, since he was once one of those wizards. So he might be able to tell the flameskull to stand down or that a particular PC was permitted in the area, even if he could not override its instructions to always return to the Smelter or tell it who to attack.