Release lock while freeing dead thread's stack to prevent deadlock.
Improvements to keyboard driver.