This procedure waits until the queue of characters for a terminal is empty (because they’ve all been sent!) and then calls “flushtty” to clean up the input queues.
“wflushtty” is called (3053) by “klclose”. This does not happen very often – in fact only when all files referencing the terminal are closed i.e. usually only when the user logs off.
It is also called by “ttystty” (8589) just before the terminal environment parameters are adjusted.