People face various income risks, including events such as job loss and illness – some of which are foreseeable while others are not. Understanding how and when people can mitigate and avoid the cost of these events is of fundamental importance to public insurance. However, empirical evidence is limited due to difficulties in measuring risks and the choices people make to avoid them, compounded by challenges in separating adverse selection from causation in the data. In this paper, we make two contributions toward filling this gap. First, we offer causal evidence on layoff costs using quasi-experimental variation in firm closures in Norway. The key to our empirical approach is that bankruptcy judges are randomly assigned and vary in how often they liquidate the firm. Combined with administrative records tracking job changes, wealth, and income, we begin by showing that layoff causes lower employment rates and jobs in lower-quality firms, leading to lower wages and disposable income. We then show that the average impacts mask important heterogeneity. About half of employees in non-treated firms escape layoff risk in normal times by leaving their distressed (but surviving) firm and moving to higher-quality firms. In contrast, we find liquidation causes a large impact on earnings and income in recession years – suggesting that fewer employment opportunities during recessions drive the layoff costs. Our second contribution is to develop and calibrate a model where people face aggregate and idiosyncratic layoff risk and make precautionary savings and job search decisions based on early information about layoff risk. We calibrate the model against our reduced form evidence and use it to quantify how on-the-job search interacts with public and private insurance and shapes the disparate effects of job loss over the business cycle.