Automate SSH script works 20% of the time but fails at the last step the other 80%

Hi everyone. I’m a scripting newbie hack, but fortunately found a nice 10-year old thread here to help me accomplish a task. My goal is to script an SSH session to shut down a server. Using DJ_Bazzie_Wazzie 's technique discovered in the older thread, I’ve created this adaptation that works, but it only works 20% of the time. The other 80% of the time it fails at the last step of sending the final “yes” to confirm server shutdown. It only sends “y” and then stops. What’s strange is that everything up to that point works fine: SSH key accept, password send, shutdown command issued, those all work fine. Below are the script, example of failure output, and example of success output. Does anyone have any tips that I can use to make this more consistently successful? Thanks!

set sshServer to "192.168.1.2"
set sshUser to "exampleusername"
set sshPasswd to "examplepassword"
set remoteCommand to "none"

set expectScript to "set timeout 60
spawn ssh " & sshUser & "@" & sshServer & "
expect {
	\"Password:\" {
		send \"" & sshPasswd & "\\r\"
		exp_continue
	}
	\"yes/no?\" {
		send \"yes\\r\"
		exp_continue
	}
	\"admin:\" {
		send \"utils system shutdown\\r\"
		exp_continue
	}
}"

set theResult to do shell script "expect <<<" & quoted form of expectScript

Here is an example of the failure output:

"spawn ssh exampleuser@192.168.1.2

(exampleuser@192.168.1.2) Password: 
Command Line Interface is starting up, please wait ...

   Welcome to the Platform Command Line Interface

VMware Installation:
	2 vCPU: Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
	Disk 1: 110GB, Partitions aligned
	16384 Mbytes RAM

admin:utils system shutdown

Do you really want to shutdown ?

Enter (yes/no)? y"

And here is an example of when it works correctly:

"spawn ssh exampleuser@192.168.1.2

(exampleuser@192.168.1.2) Password: 
Command Line Interface is starting up, please wait ...

   Welcome to the Platform Command Line Interface

VMware Installation:
	2 vCPU: Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
	Disk 1: 110GB, Partitions aligned
	16384 Mbytes RAM

admin:utils system shutdown

Do you really want to shutdown ?

Enter (yes/no)? yes


 Appliance is being Powered - Off ...
Warning: Shutdown could take up to 5 minutes.
Stopping Service Manager...