Total-time-derivative invariance of a Lagrangian
= Total-time-derivative invariance of a Lagrangian
Replacing a Lagrangian by
$$
L'(q,\dot q,t)=L(q,\dot q,t)+\frac d{dt}F(q,t)
$$
adds only the endpoint term $F(q(t_2),t_2)-F(q(t_1),t_1)$ to the action. Fixed-endpoint variations therefore give the same Euler--Lagrange equations.