We study a dynamic macro model to capture the trade-off between policies that simultaneously decrease output and the rate of transmission of an epidemic. We find that optimal policies initially restrict employment but partial loosening occurs before the peak of the epidemic. The arrival of a vaccine (even if only a small fraction can be vaccinated in the short run) implies a relaxation of stay-at-home policies and, in some cases, results in an increase in the speed of infection. The monetary value of producing a vaccine decreases rapidly as time passes. The value that society assigns to averting deaths is a major determinant of the optimal policy.