Just remind yourself that they're not real. It might sound simple, but constantly telling yourself that can help.
One way is to diversify your interests. Engage in a variety of activities so that your emotional energy isn't solely focused on fictional characters. Another tip is to consciously analyze the story and characters objectively, rather than getting swept up emotionally.