This is a primary reason we decided to get passport cards with our passport renewals this year. While they do not qualify as full passports for air travel back to the U.S., they are still a substantial form of ID and we plan to use them from now on as our 'port ID', and would also expedite issuance of travel documents from the State Department should we need them.
We also never leave the ship without two credit cards - a different one for me and a different one for my wife. One of these is normally an American Express card and not because they are widely accepted for purchases. American Express is still a 'travel related services' company and therefore they have a lot of ability to help stranded card members.
If a cruise ship knows a passenger will be late, they will not leave if they can help it. While this is the case for ship-sponsored tours in most cases, it isn't always true. Ships have had to leave port even though one of 'their' tours had not returned on time. The port authority has final say on when ships come and go, and if they say 'you will leave now' then that is what the ship will have to do.
It is quite rare to happen, but it does. Just be prepared by having ID, a source of funds, and do not panic.