Clean up thread handling for the example terminal.

* All output events are directly handled on the SbtClient thread.
* All input events are passed into a queue and handled on the main thread.
* One remaining use of global for requesting autocompletions.