This question already has an answer here:
No matter how many fences I put up my villagers always fall into the portal and into the nether. Is there a possibility that there is a way to turn the portal on or off? I know you basically start a fire and the portal opens. Can I snuff out the fire without destroying one of the portal blocks?