Countries with mandatory military service prevent their citizens / conscripted residents from freely leaving, to varying extents.
At one end any sort of compulsion means that a citizen who does not wish to give their time and energy to their government is not truly free to leave until they have fulfilled the obligations imposed on them (usually by the actions of their parents). At another end, for example, Singapore only provides passports of short validity to boys aged 13-21 and also requires their parents to post a large sum of money if they wish their sons to leave the country, even for short trips.