Just a small distinction: you are free to legally leave the US at any time. The US has no exit controls[1]. They do not even monitor who leaves at all, so they have no real idea or care, about who is leaving the country. It is perfectly legal to leave the US without a US passport, or any type of passport or ID.
Now the countries that share borders with the US, may not let you enter through a legal port of entry, but the US is not stopping you from leaving.
---
[1] https://en.wikipedia.org/wiki/Border_control#Exit_controls
This freedom should not be taken for granted, as countries accross the entire spectrum of tyranny do monitor exits - from China to the Schengen Area countries, and many in-between.
And if you want to see it taken a step further, scroll down to the exit permit system, where it would be illegal for you to leave your own country, unless you have an exit visa.