Not sure if ping is the right solution. A lot of services use icmp to check availability of a host so this could result in the server going down randomly. I once read a LJ article on port knocking. The idea is to parse the firewall logs for a certain knock sequence and then take appropriate action. Like opening up a port or something. This sure can be expanded to call shutdown on receiving a predefined shutdown knock sequence.
Here's the article:
http://www.linuxjournal.com/article.php?sid=6811
edit:
oops. I guess I misread your question as well. The keyword being
automatically shut down the server... Yeah, then the port knocking thing is not such a good idea.