Move KEY out of kernel, and make it call BYE on EOF.
The reasoning is that when KEY has no input to return, it would hang
forever.  So the program might just as well terminate.