is that level 5?
it was an intentional design to make the key door close when taking the key.
if you get the key on the left with the girl it will open up a door which is an alternate way to get back to the teleporter