Works but termination fails