Countries with intermediate levels of institutional quality suffer larger output contractions following sudden stops of capital inflows than less developed nations. However, countries with strong institutions seldom experience significant falls in output after capital flow reversals. We reconcile these two observations using a calibrated DSGE model that extends the financial accelerator framework developed in Bernanke, Gertler and Gilchrist (1999). The model captures financial market institutional quality with creditors' ability to recover assets from bankrupt firms. Bankruptcy costs affect vulnerability to sudden stops directly but also indirectly by affecting the degree of liability dollarization. Simulations reveal an inverted U-shaped relationship between bankruptcy costs and the output loss following sudden stops.