They could immediately change the topic to something more positive and friendly, like a recent movie they watched or a new hobby they are trying. And also gently remind the friend that such topics are not suitable for their friendship. If the friend persists, it might be necessary to have a more serious conversation about boundaries.
Well, first of all, they should express their discomfort clearly. Good friends should respect each other's feelings. Then, they can try to shift the focus to other aspects of their relationship or other general topics. It's important to maintain the positive and healthy nature of the friendship. For instance, they could start talking about a shared memory or a future plan they have together, rather than dwelling on the inappropriate topic.
A good friend should firmly but politely stop the conversation. For example, say 'This topic makes me uncomfortable. Let's talk about something else.'