Do you mean you have different result when you press Enter key to execute the script in dom0 terminal on laptop keyboard and on USB keyboard?
Maybe the pressed Enter key on the USB keyboard when you shut down the sys-usb is causing some issue. Try to change the script to this:
#!/bin/bash
sleep 3; date; qvm-shutdown --wait sys-usb; date; qvm-prefs sys-usb template default-dvm; date; sleep 3; date; qvm-start sys-usb; date
And don’t press any keys on the USB keyboard after pressing and releasing the Enter key to run the script.
Also check the log in /var/log/xen/console/guest-sys-usb-dm.log.