Fred’s death here and the title of this episode (Shells) was foreshadowed in season 4. In the episode 4x20 (Sacrifice) Fred and Gunn are talking about how Angel has cut himself off from his emotions while on the run from Jasmine:
Gunn- “You heard Angel. Feelings don’t enter it anymore.”
Fred- “That the world we’re fighting for? The right to be heartless, an uncaring shell, to be dead inside?
Then they talk about their shared guilt over killing the professor and then Fred disagrees with Angel’s approach by saying she allows herself to feel those emotions even negative ones like guilt when she tells Gunn: “well I don’t know about you, but…I’d take that over being a shell any day.”