The login isn't in the script, that's osbot ... You know you can load a f2p world on the cli right? (-world 316)
Well if you start a script and it failed to login the script instance will exist and will open the gui after you login... that's not the script messing up, but the client behaviour ...
Stopping and restarting fixes this indeed, but not needed when you start the client by cli in the right worlds