The bigger problem is that it's not a crime to take someone's passport away and prevent them from leaving the country whenever they wish to. None of this would be possible if an employee could quit and go home at any time.
These workers origin countries also share the blame, they refuse to help them. In many cases they turn a blind eye to this slavery since these enslaved workers send currency to their origin country.
The embassy will then confirm your identity (there are various ways).
There are girls that were raped being publicly lashed for having sex or in some cases even for getting pregnant outside of marriage. Easy to draw scenarios to keep them.
Or the typical Eastern European or African slave: they get a simple message: "if you complain we kill your little sister (or send her over to take your place!!)".