ensure that we stop reading input when we see eof
when an error is received, state is invalid - kill the process