It is very unlikely that a planet orbiting a star going supernova survives this event, but suppose an Earth-like world that encounters a neutron star passing really nearby, the planet could be captured. Some pretty uncommon orbital mechanics would need to be involved (a second planet, probably a Jupiter-sized gas giant in the right place could do the trick) The velocity of the intruding neutron star cannot be too high however, capture requires velocities that are comparable to each other. If the disrupting object goes too fast, only orbital disruption can take place.
If an actual collision with the Sun would happen, the neutron star would pass through unharmed, but the Sun will experience such a hefty energy outburst that any Earth like planet will be burned and boiled bone dry.
After being snagged by the neutron star, the planet will experience some really big tidal effects, and it will freeze over. That would be a big extinction event, but not total sterilization.
Imagine an advanced technological civilization that has survived such a cataclysm by sheltering on the bottom of the oceans, deep under a thick ice crust that shields the deadly radiation from the neutron star. The planet remains heated internally because of the elliptical orbit, so a layer of water remains liquid underneath the ice.
Maybe this advanced civilization could also have bio-engineered a totally new ecosystem that can exist under the dark conditions known on Earth around "black smokers", and possibly on other worlds in our own solar system such as Europa, Titan and Enceladus. And bio-engineered themselves to be able to live permanently under high-pressure conditions. Living to the surface is possible only with technological help.
Travelling through different galaxies is possible if the neutron star and its captured planet(s) exceeds the escape velocity of the home galaxy, but reaching another galaxy will take millions of years at relativistic speed. Which is ruled out by the capture requirement, so count on billions of years in intergalactic space with absolutely nothing to encounter.
Much more interesting is the wandering neutron star and its companion passing through a region with extremely high star density, such as a globular cluster. Every few centuries, a new star can be passed by.