How to execute commands, after exiting ADB shell?
Write your script a little different:
#!/bin/bash
adb shell &lt;&lt;EOF
...
&lt;open app menu&gt;
&lt;open app settings&gt;
&lt;save app backup&gt;
...

EOF

adb pull /storage/emulated/0/Backups/ ~/Documents/phone

All between &lt;&lt;EOF and the EOF standing separately at the start of its own line is run in adb shell, all outside is run on your local machine. Note: no exit needed.