I did the same thing when my bloodfire shrimp molted the first time. I literally went "OMFG! WTF? WHAT THE HELL HAPPENED TO MY SHRIMP?!?" then I saw him pop out from the rock like, "Sup?"
The other day, I literally scared him out of his skin. I had to move his favorite piece of rock to get at some raw shrimp the puffer didn't finish eating, and I didn't even know the shrimp was molting, but when he darted off backwards to move away from me, he literally darted himself right out of his exoskeleton. I jumped away from the tank and started laughing uncontrollably.