When somebody starts gossiping, change the subject.
When somebody starts in with all the negativity, change the subject.
When somebody starts speaking offensively or crudely, change the subject.
But how?
Just ask, “May I change the subject?”
Don’t explain yourself. Don’t apologize. Just ask, and see what happens.