We characterise the value function of the optimal dividend problem with a finite time horizon as the unique classical solution of a suitable Hamilton.Jacobi.Bellman equation. The optimal dividend strategy is realised by a Skorokhod reflection of the fund's value at a time-dependent optimal boundary. Our results are obtained by establishing for the first time a new connection between singular control problems with an absorbing boundary and optimal stopping problems on a diffusion reflected at 0 and created at a rate proportional to its local time.