I had 6 do the same thing when I put them in an uncycled tank. Some were still alive walking across my floor. Must have been out the tank for hours too.
When I had an open topped planted tank, the same thing happened to me! One time, I was sitting there looking at the tank and one just shot right out! Crazy things!
I've got them in a tank now which is pretty much covered, there is a small gap big enough for a shrimp, but it's about 1 1/2 centimeters above the waterline and has no wires coming out of it, so it should be okay
Got a tip for you mate.. put sponges in any holes. They are squishable so they perfectly fit any hole, and they can be wrapped around leads and things.