This is a very technical topic. Resolution of a bank is initiated when it is no longer viable or likely to be no longer viable, and has no reasonable prospect of becoming so. How this viability is determined and what happens afterwards depends significantly on the accounting, legal and regulatory standards of each country and the type and size of the bank.
But the main point behind the complexity is that the bank is bust and somebody will have to foot the bill.
After the financial crisis there are substantial new procedures put in place to make easier the resolution of insolvent banks. A good starting point for going deeper is the website of the Financial Stability Board.