I'm seeing a similar issue to MBP 2013 becoming unresponsive to keyboard and mouse, but this is with no external USB devices at all.
Periodically/intermittently, my keyboard and trackpad will stop responding, and I am forced to hold the power button down to shutdown and restart the laptop.
It was being triggered most frequently when plugging and unplugging an Arduino, but has happened on occasion after resuming from sleep with no USB devices connected. It was possible on some occasions to plug in an external keyboard and mouse and shutdown cleanly, but that does not seem to be possible more recently, perhaps since I upgraded from Yosemite to El Capitan (clean install, trying to solve this issue).
The MacBook Pro (Retina, 15-inch, Late 2013) keyboard and trackpad become completely unresponsive, the only working "input" is the power button, which I guess bypasses the USB stack entirely.
I have got to the point of installing PowerKey, and running a script that will trigger a shutdown and restart if the power button is pressed repeatedly in a short time. At least this will give programs a chance to save their state before shutdown.
What I'm really looking for is how to reset the USB stack entirely. I tried the following:
$ sudo kextunload -b com.apple.driver.usb.AppleUSBXHCIPCI $ sudo kextload -b com.apple.driver.usb.AppleUSBXHCIPCI
and then reloading it, but that left the keyboard and mouse unusable still. (I tried this via SSH, before the problem manifested itself. i.e. the keyboard and mouse were working prior to the kextunload)
I then tried doing a diff of the loaded kext's before and after the unload, and reloading all the other kexts that were removed, but that still did not result in a working keyboard.
Any suggestions? Do I need to load the kext's in a particular order, perhaps? Is there a script/program that knows what that order is (I assume so, since they get loaded successfully on startup!)