Can a bank stop you from closing an account?

If the account is in debt you cannot close the account without settling (paying off) the balance. Otherwise it is your right to decide on whether you want to keep the account or close it.