We analyse a portfolio optimization problem for a long-term investor in the presence of stock market crises. A crisis includes a crash of the stock market price, a sharp increase of its volatility and dramatic deterioration of liquidity. We model the stock market illiquidity by means of convex transaction costs that mimic the presence of an effective bid-ask spread that increases with the size of a trade. We find that the existence of stock market crises results in a significant liquidity premium. Furthermore, the presence of background risk has a negative impact on the liquidity premium.