This paper extends Mortensen and Pissarides (1994) by introducing workers' risk aversion. In doing so, it provides a framework within which to study jointly the optimal supply of job security and the allocational and welfare consequences of government intervention in excess of private arrangements. Firms offer insurance in the form of simple explicit employment contracts featuring productivity-independent wages and severance pay. Contracts can be renegotiated ex post by mutual consent. Laissez-faire contracts are never renegotiated and fully insure workers. Positive severance payments are part of an optimal contract whenever employed workers enjoy positive rents over their unemployed counterparts. The optimal severance payment size is increasing in the expected income loss associated with job mobility. Hence it is positively related to unemployment duration. We present empirical evidence that legislated job security is positively correlated with the optimal severance pay according to the model. Such evidence cannot be explained in terms of reverse causation from high state-mandated job security to high job duration. Legislated firing costs well in excess of privately optimal ones have negligible welfare effects and a small negative impact on unemployment and its duration as wages fall to minimize the distortion.