Depends on what kind he is. If you can handle it relatively easy without injury on your part, just very gently grasp him and very slowly lift him off of the glass/rocks/whatever. He will eventually let go and stick to you with his feet.
If he's one with really sharp spines, use a pair of tongs and gently lift him off the glass, lift from one side, trying to pull one straight up is like trying to peel a cat off a screen door.
If you are slow and careful, you will not hurt him at all.