I own a company that does asset investigations/recovery work for banks and attorneys. Much of what we do involves cases pre and post foreclosure.
It all depends on the bank. If the foreclosure does not clear the balance, many will pursue a deficiency judgment. If they are successful, you not only lose your property but you have to face the prospects of someone trying to recover the judgment.
Also, if there is a shortfall, they will most likely report that amount as income to the IRS, and you will owe taxes on it.
From my experience, those that come out the best are those who are highly involved in working with the bank towards a solution. Generally, those that fare the worst are those that let this happen without getting involved.