Use term.redirect for ProgramWindow.

Wrap the program inside another coroutine which redirects/restores the
terminal with each resume.
Terminal fixes.