Pointless, improbable, and not a concern
It is a deterrent? Not really, no, because you can expect space battles to happen at such long range that the enemy will not be caught in any such explosion. A mere kilometer/mile or so away from a nuclear explosion in space, a ship will be relatively safe. This is because the main effect of a nuclear explosion is the shock wave. Since there is no atmosphere in space to propagate the shock wave, a nuclear explosion in space is not nearly as violent as one on the surface of Earth. Instead the main effect will be heat heat pulse and the radiation pulse. Both of these diminish quickly by the square of the distance to the explosion.
It is also not technically credible. Fission reactors cannot be brought to explode in any kind of spectacular fashion. During the Chernobyl accident — which by any and all accounts must be considered a worst-of-the-worst scenario — people in the control room were not aware the reactor had ruptured in two separate explosions for several hours. Fusion reactors would be even less likely to explode since they will be dependent on a steady flow of fusionable fuel into the reactor to even keep going. Anti-matter reactors? Well... there we could get a sizable explosion going. But if so then there must already be anti-matter weapons. If a dying ship is to give one last "Good Game, and F*CK YOU!" salute, then I would rather expect the ship to send out all its missiles/kill drones for that, especially since the risk of Friendly Fire is significant with the ship blowing up.
Further more, in case the ship needs to be destroyed then that must be a controlled and deliberate action, or through a dedicated mechanism that guarantees the proper execution. Otherwise you cannot be sure of when it happens nor how effective it is. If you have made the decision that the ship will be scuttled, then you need to know this will actually happen, and you will not be left with a fizzle that leaves most of the ship intact.
As for the environmental concerns: no... that is a complete non-issue. A star bombards its planets with so much radiation that a nuclear bomb in space is like tipping over one of those water bottles...
Obviously the self-destruct trope — both deliberate and inadvertent — still manages to make its way into fiction all the time. Usually though it is for any of the following:
- Prevent capture and with that a fate worse than death
- Prevent valuable resources from falling into enemy hands (such as secrets, technology and crew members)
- For glory! ...or at least to spare us from having to live through the shame of defeat.
- We ram them and take them with us. There is a subtle difference here in that this is a deliberate and controlled action whereas what you propose is happens when the defeated have lost all control.
- Convenient tension generator that adds excitement to the narrative
But mutual destruction in your average space battle very rarely seems to do it.
So to answer your question: is there any narrative value in the idea of having the protagonists pull out their reactor fail-safes in the event of a space battle? No, it does not make any kind of sense. It is too uncertain, too uncontrolled, not technically plausible, and most likely pointless.