Allegro's keyboard buffer is used from multiple threads, but it's not thread-safe. It has a lock variable, but it's an ordinary int. If that gets messed up, the keyboard is permanently locked, and the GUI stops responding to keyboard input. The buffer isn't accessible outside of Allegro itself, so it can't be corrected when it happens. I've made efforts in the past to reduce the likelihood of it happening, but it's not something we can entirely fix.
I can have it clear the buffer when switching in or out, which should fix the issue with it thinking keys are being held, but that also significantly increases the odds that the keyboard will stop working entirely.