Yeah, Germany tried that once, and it failed.
Also how is it even possible in principle? Surely, even if immigration is completely restricted, foreigners can still live in the country. And during that time, people might get into relationships or get married and have mixed-children. Or should the state forbid international marriages like North Korea does? What would happen to those children? Should they be deported or something?