It kind of is. You try to leave, the police stops you. You go to court, the court decides against you. What's not "lawful" about that (aside from the very unjust nature of China's laws)
Every country has laws about who can get passports. In countries without proper rule of law this is often arbitrary. Does that mean all those countries have made emigration illegal?
> If the law also says you can't leave without passports, like Chinese law,
Other countries don't let you in without a passport. Even in the absence of a Chinese law, an airline would deny you boarding if you didn't have a passport.