Stay calm! Just being out of the shell will NOT kill your crab. First take the old shell and rinse it out well to ensure there is nothing in it that could be poking into your crabs soft abdomen. Rinse the shell (and your hands if you intend to touch the naked crab) with dechlorinated water or ocean water. Place the shell in the bottom of a small bowl or container. Add a tiny amount of dechlorinated water to the bottom of the bowl as well. Gently pick the crab up or use a spoon to gently scoop it up. Place it carefully in the bowl next to the shell. Place the bowl into your main tank. If you have a isolation tank set up you can use it instead. Cover the bowl with a towel to make it dark. Give the crab time to put the shell back on. As a final effort, you can try to ease the crab back into its shell. I’m not sure how successful this has been for others but I know it has been attempted.
Typically when your hermit crab leaves it’s shell, that is a sign of stress or something amiss. Once you have the hermit crab back in its shell, try to determine what may be the cause of its stress. I would recommend leaving the hermit crab in isolation for a bit to make sure he keeps his shell on.