The holy Zohar tells us that when Shabbath ends, large bands of evil spirits fly around the world. It is on this account that we recite the Mizmor (Psalm) "Yosheb Besether 'Elyon" after the 'Amidah at the conclusion of Shabbath, because it has the power to ward off these spirits. The Zohar tells us that when they see the holy people reciting prayers, psalms and Habdalah, they flee.
Hakham Yosef Hayyim, 'a"h, writes in Ben Ish Hai that the evil spirits are chased away in three stages. The first is during the Habdalah recited in the 'Amidah. This has the power to uproot the inner strength of these harmful spirits. When reciting the Mizmor after it, the middle power is uprooted and removed.
Finally Habdalah is recited loudly (over the cup of wine). This has the effect of uprooting the external power of the spirits. At this point, their strength has been completely removed and they flee to the wilderness, as is explained by the Zohar.
(See Zohar, Bereshith, pg. 14b., Ben Ish Hai, 2nd year, Wayyesei, Oth 4)
Zohar, Havdalah, Habdalah, demons, evil spirits