Interestingly enough, there was a version of the script where the scene played out much differently. In a spoiler-heavy interview with New York Times, screenwriters Christopher Markus and Stephen McFeely had this to say:
Markus: And it was true, it was him taking the hit for her. It was melodramatic to have him die and not get his family back. And it is only right and proper that she’s done. McFeely then went on to explain why Black Widow’s death was right for her character. There’s simply no denying that the pairing of Markus & McFeely and the Russo brothers really understand the core of these characters on such an intrinsic level. All three major departures felt true to their characters and held plenty of emotional weight. The toughest thing for us was we were always worried that people weren’t going to have time to be sad enough. The stakes are still out there and they haven’t solved the problem. But we lost a big character — a female character — how do we honor it? We have this male lens and it’s a lot of guys being sad that a woman died.” (Source: New York Times)