Yes, this is legal, but the specific details depend on where you live. In general, it would be a form of Citizen's arrest. Georgia law previously defined it as:
A private person may arrest an offender if the offense is committed in his presence or within his immediate knowledge. If the offense is a felony and the offender is escaping or attempting to escape, a private person may arrest him upon reasonable and probable grounds of suspicion.
In other words, if either he has already commited a crime before trying to leave, or if you are have reasonable suspicion that the person came to commit a felony, then you were allowed to trap him as he is attempting to escape.
The requirements for performing this citizen's arrest vary much from state to state. Just recently Georgia changed their law to apply to business owners suspecting theft, and a couple other cases. Other states allow the use of non-lethal force in order to effect such a citizen's arrest. Texas even allows the use of lethal force, if necessary, to keep the person from leaving your property until law enforcement comes.
More jurisdiction-specific details on citizen's arrest can be found on Wikipedia.