correct handling of protocol termination