Yes. Most nations require that you pass through them to obtain an admission stamp for your passport. Then, to make sure you did not exceed your visa-free period, the immigration officer will check your passport as you leave the country to look for the entry stamp.