AFK mode is meant to completely ignore the attack option, maybe you need to set a safespot tile as well for it to work effectively.
I'm not sure why it would run to the bank, do you run out of food or have enabled potions? Are you picking things up and getting a full inventory?