We study an asymmetric simple exclusion process in a strip in the presence of a solid impenetrable barrier. We focus on the effect of the barrier on the residence time of the particles, namely, the typical time needed by the particles to cross the whole strip. We explore the conditions for reduced jamming when varying the environment (different drifts, reservoir densities, horizontal diffusion walks, etc.). In particular, we discover an interesting nonmonotonic behavior of the residence time as a function of the barrier length. Besides recovering by means of both the lattice dynamics and the mean-field model well-known aspects like the faster-is-slower effect and the intermittence of the flow, we propose also a birth-and-death process and a reduced one-dimensional (1D) model with variable barrier permeability to capture the behavior of the residence time with respect to the parameters.