However, if you are not sure if your crab is molting or dead, how you handle the situation may make the difference between life or death if your crab is indeed just molting.
Assume your Hermit Crab is Molting!
The safest thing to do is to assume your crab is molting. If you disturb a molting crab at a critical time while trying to determine if he is alive or not, the results can be disastrous.
If your crab appears lifeless and is in an isolation tank, leave him alone and watch to see what happens. If your crab is in the main tank (especially if she is on the surface), cut the ends of a 2 litre pop bottle and sink it down into the sand to surround the crab with a protective barrier.
Do not disturb a crab that is limply hanging out of her shell (just protect her from other crabs). If she is molting, she should continue through the process given time. If she has died, she will start to smell very badly (rotting smell, often "fishy") within a few days.
A crab that is just buried is a bit trickier. Smooth the sand around his hiding spot and look for tracks to get an idea if he is coming up at night for snacks. My crabs often disappear during the day, but the tracks around the cage in the morning (and the sand in all the dishes) lets me know that they are still active. If it has been weeks since your crab buried itself, you can carefully sweep off a bit of sand from around his hiding spot to check for a rotting smell.
If you find what appear to be a dead crab next to a shell, have a closer look to see if it is just an exoskeleton (if is it hollow and crumbles easily, it is an old exoskeleton). Have a quick peek in the nearby shell and you might find a molted crab hiding out. Similarly, a molting crab may leave limbs strewn about, which can be a bit startling.
Go To Hermit Crab Molting FAQ for more on molting hermit crabs