There are lots of ways to do this. Many servers have similar scripts to despawn enemies from areas that the PCs have left, to reduce potential lag caused by the AI for too many NPCs hanging around when there is no one there to interact with them.
One approach is to have a heartbeat script for the area that runs and checks whether any PCs are in the area and, if not, despawns your quest helper NPC. I tend to worry that this approach can cause lag if too many such scripts are running all the time. And, it can complicate bookkeeping if you want to customize the despawn with a delay or a check of multiple areas or whatever.
Another way (one that I tend to prefer) runs on the area's OnExit event. Whenever a PC leaves the area, check if any other PCs are still in the area. If not, then despawn the helper NPC. There are some caveats about this. For one thing, it's often useful to do this in two stages. First check that no PCs are in the area and, if not, set a timer to run another check after some delay (1 minute, 5 minutes, etc.) and only despawn if there are still no PCs in the area. That way, people who leave an area and come back soon after will still find the NPCs in the same places and so on. Another potential issue when removing NPCs is to make sure that no important variables are stored on them, since those variables won't be there when they are respawned. You can also expand such a scheme to check several maps before despawning the NPC. Basically, the first script checks for PCs in several areas and, if there are none, sets up the second script.