As far as I'm aware, banks reserve the right of offset in this type of situation; in reality they could have closed the account (or at least taken the entire balance) and placed the funds on the loan.
I'm in Indiana, however. Things may be different for your state.
_________________________
My opinions do not necessarily reflect those of my employer.