Let’s say we fire our bullet at normal speeds for a pistol (about 1000 feet/second, or 0.3 km/s). If you were on the International Space Station, which orbits at ~270 miles above the surface of the Earth, when you shot your pistol, you would need to fling something at 10.8 km/s to escape the orbit of the earth. Even considering that the ISS is already moving at 7.7 km/s, the speed of the bullet (an extra 0.3 km/s) is nowhere near enough to escape the earth’s gravity. Your bullet has just become another piece of unstable space junk, and will eventually fall back to earth, probably burning up in the process - it’ll look exactly like a shooting star.
Even on the moon you need a velocity of more than 2.5 km/s to not have your bullet land somewhere else on the moon. That’s more than even the highest powered of tanks can deliver (they max out at 1.7 km/s - a high powered rifle can only get up to 1.2 km/s)
So, say you’re outside the solar system, and you fire your gun, which is your best case scenario for getting the bullet to go the furthest, the bullet will still be stopped, since you’d still be in the galaxy. Given that the galaxy is mostly empty space, it’s unlikely that the bullet will smack directly into something. However, the bullet is not very heavy, and it’s going at an extremely slow speed for an astrophysical object, which means it doesn’t have a lot of momentum keeping it going forward. This seems like an odd thought, since a bullet’s momentum can deliver enough damage to a human to kill them, but we’re delicate creatures and we don’t handle changes in energy very well.
So unless you were completely outside the range of the gravitational pull of our galaxy and any other galaxy when you fired the gun (which would be a very difficult place to get to), the bullet will definitely stop. If the bullet got near anything that had more of a gravitational pull than the energy of the bullet going forward (which isn’t much), it will slowly turn towards that larger object, lose energy and slow down. It’s hard to say when it will officially “stop”, because there’s no absolute frame of reference for that sort of thing, but we could safely say that eventually, the energy of the initial gunshot will no longer be dictating the motion of the bullet.
Something unclear, or make you think of another question? Feel free to ask!