Prevented slave from (re-)registering when TERMINATING.

Checked the slave's state before (re-)registering.
Introduced EXPECT_NO_FUTURE_PROTOBUFS() and EXPECT_NO_FUTURE_MESSAGES().

Review: https://reviews.apache.org/r/21968