In the olden days, these towns wouldn't pay you money, they would pay you scrip issued by the mining company[0]. This could only be used at company-operated stores, so miners were imprisoned in the towns. Moving back literally wasn't an option for the people that worked there, but if there was no other jobs around, where else could you go?
[0]https://en.wikipedia.org/wiki/Company_scrip