Nightmare Haunting (1/Day): While on the Ethereal Plane, the hag magically touches a sleeping humanoid on the Material Plane. A Protection from Evil and GoodProtection from Evil and Good spell cast on the target prevents this contact, as does a Magic CircleMagic Circle. As long as the contact persists, the target has dreadful visions. If these visions last for at least 1 hour, the target gains no benefit from its rest, and its hit point maximum is reduced by 5 (1d10). If this effect reduces the target’s hit point maximum to 0, the target dies, and if the target was evil, its soul is trapped in the hag’s soul bag. The reduction to the target’s hit point maximum lasts until removed by the Greater RestorationGreater Restoration spell or similar magic.
So in order to "prevent" contact, you wait for the Night Hag to arrive, then you cast the spell. But how does the party even know the Night Hag is there? See InvisibilitySee Invisibility can be used to see ethereal creatures, but it only lasts an hour, and the Night Hag can come any time during the night.