We develop a model in which, in order to provide managerial incentives, it is optimal to have costly bankruptcy. If benevolent governments can commit to their policies, it is optimal not to interfere with private contracts. Such policies are time inconsistent in the sense that, without commitment, governments have incentives to bail out firms by buying up the debt of distressed firms and renegotiating their contracts with managers. From an ex ante perspective, however, such bailouts are costly because they worsen incentives and thereby reduce welfare. We show that regulation in the form of limits on the debt-to-value ratio of firms mitigates the time-inconsistency problem by eliminating the incentives of governments to undertake bailouts. In terms of the cyclical properties of regulation, we show that regulation should be tightest in aggregate states in which resources lost to bankruptcy in the equilibrium without a government are largest.