In this work we solve in a closed form the problem of an agent who wants to optimise the inter-temporal utility of both his consumption and leisure by choosing: (i) the optimal inter-temporal consumption, (ii) the optimal inter-temporal labour supply, (iii) the optimal share of wealth to invest in a risky asset, and (iv) the optimal retirement age. The wage of the agent is assumed to be stochastic and correlated with the risky asset on the financial market. The problem is split into two sub-problems: the optimal consumption, labour, and portfolio problem is solved first, and then the optimal stopping time is approached. The martingale method is used for the first problem, and it allows to solve it for any value of the stopping time which is just considered as a stochastic variable. The problem of the agent is solved by assuming that after retirement he received a utility that is proportional to the remaining human capital. Finally, a numerical simulation is presented for showing the behaviour over time of the optimal solution.