Then log the pos throughout the script and check where it changes. There is no internal code in our API to change your variables values, it's definitely a logical error in the code.
You walk to the bank using webwalking, then use webwalking to get back not normal walking as it's probably no longer in the currently loaded region or cannot be reached without going through obstacles
Set the value of pos to the current player's position (myPosition()), not the tree position. You cannot walk back to the tree position because that's not walkable, there's a tree blocking that position.
Make sure the quest list is the tab that will open in the quest tab not minigames or adventure path
Bank tab set on "all", check if it attempts to switch tab. If it does collapsing should fix this
Where are you starting the script? Did you try at GE since it's trying to restock?
Make sure that before starting the script you close any adventure paths related things (and switch to quest tab if on minigames/adventures paths/other), also switch to main tab on bank if it's on another