In the derivation of the Euler-Lagrange equation in Peskin and Schroeder, p.15, we have:
$$\delta S = \int d⁴x \left[ \frac{\partial L}{\partial \phi}\delta \phi -\partial_\mu \left(\frac{\partial L}{\partial (\partial_\mu) \phi}\right)\delta \phi + \partial_\mu \left(\frac{\partial L}{\partial (\partial_\mu \phi)} \delta \phi \right)\right]. \tag{2.2} $$
They argue that the last term can be turned into a surface integral, and since the initial and final field configurations are given, $\delta \phi$ is zero at the temporal beginning and end of this region. If we restrict our considerations to deformations $\delta \phi$ that vanish on the spatial boundary of our region as well, then the surface term is zero.
So I guess they used the divergence theorem on the last term, but why doesn't this argument apply to the second term as well?