use thread constructor with runnable to reduce indents; add shut down hook for termios