This paper extends the project initiated in arXiv:2002.00201 and studies a lifecycle portfolio choice problem with borrowing constraints and finite retirement time in which an agent receives labor income that adjusts to financial market shocks in a path dependent way. The novelty here, with respect to arXiv:2002.00201, is the fact that we have a finite retirement time, which makes the model more realistic, but harder to solve. The presence of both path-dependency, as in arXiv:2002.00201, and finite retirement, leads to a two-stages infinite dimensional stochastic optimal control problem, a family of problems which, to our knowledge, has not yet been treated in the literature. We solve the problem completely, and find explicitly the optimal controls in feedback form. This is possible because we are able to find an explicit solution to the associated infinite dimensional Hamilton-Jacobi-Bellman (HJB) equation, even if state constraints are present. Note that, differently from arXiv:2002.00201 , here the HJB equation is of parabolic type, hence the work to identify the solutions and optimal feedbacks is more delicate, as it involves, in particular, time-dependent state constraints, which, as far as we know, have not yet been treated in the infinite dimensional literature. The explicit solution allows us to study the properties of optimal strategies and discuss their financial implications.