We introduce and study the adiabatic dynamics of free-fermion models subject to a local Lindblad bath and in the presence of a time-dependent Hamiltonian. The merit of these models is that they can be solved exactly, and will help us to study the interplay between non-adiabatic transitions and dissipation in many-body quantum systems. After the adiabatic evolution, we evaluate the excess energy (average value of the Hamiltonian) as a measure of the deviation from reaching the target final ground state. We compute the excess energy in a variety of different situations, where the nature of the bath and the Hamiltonian is modified. We find a robust evidence of the fact that an optimal working time for the quantum annealing protocol emerges as a result of the competition between the non-adiabatic effects and the dissipative processes. We compare these results with matrix-product-operator simulations of an Ising system and show that the phenomenology we found applies also for this more realistic case.