The answer is, they are NOT allowed to do this:1) They cannot physically restrain you from leaving--that is a criminal act and almost certainly a violation of various workplace safety and firecode provisions. They can lock the door to keep others out, but any employee must be able to open it from the inside if they want or necessary. If the won't stop doing this, contact the municipal fire department and building department, and/or OHSA, about the situation.2) While your employer can tell you that you will be fired if you leave before being dismissed (and then follow-through and fire you if you do leave), the time they force you to wait at work IS considered work time (because you are being held at work for the employer's benefit, at their decision) and so hourly employees must be paid for that time even if it's after shift end, including overtime as applicable.