I'm gonna hope you didn't walk in while followed by the crab and was instead exploring when it came it.
Also, what items did you have? Apart from the already mentioned use-the-key there may have been other options. The blue crab moves slower than the player which allows some room to play with.
You can bless the Ankh by throwing it in the well, either way blessing your Ankhs in a high chal run is a waste of its healing potential (can be used safely on boss floors outside boss battles)