Hi,
The error ""Failed to send keystroke to Attachmate host due to the session being occupied."" generally means that the session is still in use or the previous command which you gave is still waiting for the output to come,try giving some wait time before your ESC key.
Also check the keyboard layout for the manual user and bot user to make sure ESC key is configured correctly.
Regards,
Ravinder Saini