tl;dr:
Space is big. Unless you're near an inhabited region, you're probably not actually going to hit anything.
Planets and spacefaring species already have ways to handle stray space debris. A stray shot would be covered by those protections.
Intergalactic authorities won't care about stray bullets; they will care about weapons of mass destruction and lingering wartime hazards.
Space is Big
The quote from Mass Effect 2 is actually not true. Not every object flying through space will eventually hit something. While it's true that if it does hit something, a stray shot could ruin someone's day, most things floating through space won't hit anything.
Unless you are so close to an inhabited thing that you can see it with your naked eyes, you've got nothing to worry about. Your shots will spread out enough that any given inhabited planet or space installation more than a few light-years away will only ever be on the receiving end of between 0 and 1 shots.
In a combat situation, a total risk of all combined collateral damage under 0.1% is not only acceptable, it's fabulously, unbelievably good.
There are already protections in place
Your slug is going fast, true, but there are other fast-moving, massive objects flying around in space capable of causing destruction. A mass slug from a railgun is similar enough to natural space debris that anything capable of protecting against stray space rocks will also protect against stray bullets. Any sentient civilization will have ways to deal with stray space debris, either directly via technology, or passively such as their planet's atmosphere.
If your shots break apart into small fragments after missing their target, you further reduce the damage from any collateral hit to that of a micro-meteor. A planet might have to absorb more than 1 fragment, but a ship, even a huge one, would only have to deal with at most 1 fragment.
Intergalactic authorities won't care
Any intergalactic authorities won't care about stray shots from a railgun. They'll care about something because it is actually a problem. They would care far more about:
- minefields → mines tend to be left behind long after a war is over. They cause a large area to be needlessly dangerous far longer than was ever intended.
- area denial weapons/tools → Same basic idea as minefields. Anything that blocks safe travel in a wide area, and lasts long after the war is over, becomes at least a travel hazard.
- weapons of mass destruction (WMD) → A single stray bullet could kill a person. A single stray nuke could destroy a city and poison the land for centuries. A stray WMD has the same small chance of hitting something important as a stray mass slug. Unlike a stray mass slug, however, a WMD will ruin more than just a handful of peoples' days if it does hit.
Conclusion
You're worrying needlessly. But if you want to reduce the extremely tiny risk further, just blow missed shots up into a cloud of tiny fragments.