As Charles Stross explains, it's an easy four-step process. First, build a Von Neumann probe — an automated spaceship that can refuel, repair, and make copies of itself. Second, program the probe to hunt out likely solar systems with a good bit of planetary mass, and when it gets there, to build a Matrioshka brain. Essentially, the probe breaks down the local planets into a networked system of solar-powered computers so numerous they capture all the local star's sunlight (as seen in Stross' book Accelerando).
Third, the brain uses radio astronomy to map nearby stars and search for signs of life: oxygen absorption signatures, non-natural radio signals, and so forth. Finally, if any life is detected on a nearby planet, the Matrioshka brain aims a Nicoll-Dyson beam at it — a phased array of lasers powered by all the star's energy. Such a beam would have a range of hundreds of light-years — and could destroy an Earth-sized planet in less than an hour.
That's it! All it would take is one high-tech civilization building one of those probes, and the galaxy would be sterile until all the stars go out in 100 trillion years.