We study an optimal dividend problem under a bankruptcy constraint. Firms face a trade-off between potential bankruptcy and extraction of profits. In contrast to previous works, general cash flow drifts, including Ornstein-Uhlenbeck and CIR processes, are considered. We provide rigorous proofs of continuity of the value function, whence dynamic programming, as well as comparison between the sub-and supersolutions of the Hamilton-Jacobi-Bellman equation, and we provide an efficient and convergent numerical scheme for finding the solution. The value function is given by a nonlinear PDE with a gradient constraint from below in one dimension. We find that the optimal strategy is both a barrier and a band strategy and that it includes voluntary liquidation in parts of the state space. Finally, we present and numerically study extensions of the model, including equity issuance and credit lines.