A similar thing happened to me when I was actually attempting to board a ship. As soon as I walked up the hatch and tried to open the door, the hatch closed and the ship started moving. Couldn’t enter at that point, and I was also now trapped in the airlock as the ship was taking off into space.
Was actually a bit terrifying, because in theory I was now completely at the mercy of these pirates and had to hope they didn’t just jettison me off into space after they noticed I was there. In reality, I just phased out of the ship as it went too high up and was a bit disappointed that nothing that exciting can actually happen.