I have trouble understanding why do we ignore surface terms. To get the on-shell fields we fix the fields at infinity so these terms do not matter. However , In the path integral , We integrate over all field configurations. So we must integrate over all values of the fields at infinity. So , one shouldn't set terms like $e^{i\oint dn^{\mu}\psi_{\mu}} $ equal to one and they should contribute to the partition function. Is this correct ?