The discount window is used when the bank is unable to access the interbank market which is usually an indicator the bank is expected to fail. The discount window provides liquidity for high quality assets at high costs (which is why it is called the discount window).
If the bank runs out of high quality assets and can’t raise capital it becomes insolvent (bankrupt) and the FDIC takes over the bank and winds it down.