This introduces systematic errors called finite size effects . Have to understand these, and be able to extrapolate to an infinite system, usually by doing a number of simulations at different system sizes. For a finite system, get rounded peaks rather than divergences. The peaks narrow and increase in height as L is increased, and the location of the peak shifts slightly.
Many problems require an empirical extrapolation to an infinite system.
But for phase transitions in statistical mechanics, some elegant and useful theoretical results exist.