the pirates had rushed around , filling their pockets and hats , and putting as much as possible back on the cart , but as the last of the coins were being recovered their luck ran out and the alarm was raised .