The Shadow Queen then notices Mario and his friends and offers them the position of her servants. If Mario agrees, the Shadow Queen will engulf the world with her foul magic, resulting in a Game Over for Mario, for Peach, and for the world. When Mario refuses, the Shadow Queen attacks him and his friends, intending to put them in their place, but finds that Princess Peach's body is impeding her power. The Shadow Queen assumes her real form, and for a time becomes impervious to Mario and his friends' attacks. After several further unsuccessful attempts to attack the Shadow Queen, the battle abruptly stops just as Mario and his friends are about to give up hope.
However, the Crystal Stars manage to travel to their home locations, allowing the people of each area to communicate with Mario. The goodwill and wishes of people the world over are enough to suppress the Shadow Queen's possession of Princess Peach; she regains control of her body long enough to give Mario all her remaining power. Restored, Mario and his partners resume their battle against the Shadow Queen; they are able to defeat and destroy her forever, and Peach regains control of her own body once again.
The above text is from the Super Mario Wiki and is available under a Creative Commons license. Attribution must be provided through a list of authors or a link back to the original article. Source:
https://www.mariowiki.com/Shadow_Queen