rpc, state/api: consistent errors.
It helps to close the right thing, and there's probably
no point in sending a message to the server when it's
about to be closed.
Not easy to test, unfortunately, as triggering the
different error message involves catching the input
goroutine in just the right place.
R=
CC=
https://codereview.appspot.com/7324054