Warning: This article contains spoilers from Episode 404 of “The Americans.”

At the end of Wednesday night’s episode of “The Americans,” one of the spy drama’s ticking time bombs finally went off.

KGB officer Nina Krilova (Annet Mahendru), who had been exiled to Russia for treason, found out her appeal had been denied — and that her death sentence would be upheld. “It will be carried out shortly,” a Soviet officer unemotionally tells her.

Seconds later, as she collapses in tears, she is shot in the back of the head, her limp body unceremoniously wrapped in a tarp and carried away.

It’s an abrupt end for the tragic Nina, who this season had started making strides to be a better person, risking her own safety to try to smuggle a letter from her scientist friend Anton (Michael Aronov) to his son. But the scene preceding her death, a dream sequence in which she and Anton are freed from their captivity, will now never be realized.

Ahead of Season 4, Mahendru spoke with The Post about saying goodbye to Nina, the scene in which she couldn’t stop crying and her one regret about her character.

When did you find out that Nina would die?

In October, right before we started [filming], they [the producers] called me. You play it cool and then all of the sudden you start crying like someone literally just took a part of you. My mom just kept saying on the phone, “You’re not Nina, you’re not Nina.” It feels like a personal death. You start mourning — you’re angry, you go through all that. That was excruciating. I said, “I can’t believe you guys are doing this to me, I can’t believe I have to experience this.” It was absolutely horrible and it was also the best thing I could have done as an artist, which they told me when they called me. They were like, “Listen, this is everything an artist wants.” I was like, “Are you kidding me? No this is horrible, I don’t want to.” I was really angry with them and pissed off. It was a lot of work, but I think it was the greatest work I’ve ever had to do at the same time.

What do you think of the ending they wrote for her?

I think it was pretty epic. I couldn’t have thought of a better way. You do a few takes of it, because it was technical, but at the same time [it was] so painful — all the bad adjectives you could think of. And then they’re like, “We got it.” And you’re like, “OK, good, it’s over,” but actually what I felt was, “I want to do it again.” That’s when you know — “I’m meant to be an artist.” No matter how painful, no matter what I have to go through, I actually love this.

Was that death scene the last one you shot?

No, the last thing was actually [the scene with] Stan [Noah Emmerich] at our safe house, where we first met, where Nina started. That was my last day, so it came full circle, saying goodbye to Stan in a dream sequence. It was, “Oh my God, could this be any more sad? This is torture.” I remember Season 1, I was going in, “Oh s - - t, how am I going to cry?” And then I ended by, “How am I going to stop crying?” There are certain scenes, like when I’m meeting [my] husband — you can’t be crying in it because you’re keeping it together, you’re happy to see him — but it was so emotional meeting someone that was so close to her. So I was crying, like sobbing, up until “action” and then right after “cut” I would sob again.

Would you have changed anything about your character?

I wish that she wasn’t so tragic. I guess some people are and you can’t do anything [about it]. You wish maybe she settles down with a family, with Anton or whoever, but that’s just not who she is. I wish she had all kinds of lives, but that’s a different story. It’s not Nina’s story. I wish Oleg [Costa Ronin] came [to see her]. She could still die, I just wish they had a conversation. That’s a real bummer.

You had a role in “The X-Files” reboot recently. What do you want to do next?

I’d love to do something where I know the ending, so it’s not as brutal as this season was. I’d love to do film, maybe do a [guest] arc on a show . . . I was doing all comedy before Nina. I’m game for anything. I think I have to be as Nina: ready for anything at all times.