Divorced Parents/Boundaries

My parents are divorced. After 20 years my father still harbors hate for my mother. On infrequent visits with him, he wants to complain about my mother. I do not want to hear it. How do I properly enforce a boundary without making it seem like an ultimatum. I keep thinking I should say “if you continue to complain about mom, I will leave.” Is that correct? Or is that a threat?