Yosemite and El Capitan USB crash kills keyboard and trackpad 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!)
The start up sequence is kind of hard to emulate other than actually power cycling the computer. 

I don't have a good answer since his failure is extremely low level, but here are the things I would do to troubleshoot and isolate things before considering a total reinstallation of the OS:


run sysdiagnose script each time a failure happens to capture the logs and also gain a sense of how often this happens. 
verify that plugging in the USB keyboard does not kick start the system properly for internal or external keyboard function
log out the user using kill -9 -1 or via remote screen sharing


My guess is the logs will show USB errors indicating a hardware fault, but that would need a look at your specific logs. It's not clear why you are manually loading the kext so perhaps I'm missing some information?