added some handshaking phases for teardown.