We consider the problem faced by a central bank which bails out distressed financial institutions that pose systemic risk to the banking sector. In a structural default model with mutual obligations, the central agent seeks to inject a minimum amount of cash in order to limit defaults to a given proportion of entities. We prove that the value of the central agent's control problem converges as the number of defaultable institutions goes to infinity, and that it satisfies a drift controlled version of the supercooled Stefan problem. We compute optimal strategies in feedback form by solving numerically a forward-backward coupled system of PDEs. Our simulations show that the central agent's optimal strategy is to subsidise banks whose asset values lie in a non-trivial time-dependent region. Finally, we study a linear-quadratic version of the model where instead of the terminal losses, the agent optimises a terminal cost function of the equity values. In this case, we are able to give semi-analytic strategies, which we again illustrate numerically.