Vince Gilligan explains how it was done in the episode's commentary. You can watch it here (it starts at 05:13):
To summarise, the gun was mounted on a clear plastic dowel, which ran vertically under the table to the ground and was connected to a fishing line. The special effects crew could use the fishing line to control the spin and ensure it stopped at the right place.
VINCE GILLIGAN (director): Our wonderful on-set special-effects guys put a clear plastic dowel straight down —
BRIAN CRANSTON (Walter White): From the gun.
VG: From the gun to the ground, and then had a pulley with a bit of fish line. And they could control — Brian would spin the thing, but they could control exactly when it would stop.
KELLEY DIXON (editor): And didn't it look perfect?
VG: They did a great job. The only trouble was that everybody would keep tripping over the thing on the set there, cause it was just a bit of fish line, you could barely see it.
BC: And then you would just paint it out when you're done, right? Would you see the monofilament and the dowel?
VG: The dowel, mainly. The monofilament was never really in the shot. ... Painting out that dowel turned out the be the biggest hassle.
BC: No kidding?
VG: Bill Powloski, our visual effects supervisor, and Diane Mercer just had a hell of a time doing it, but they did a great job.
KD: You know what, even before it was painted out, we fooled a lot of people. A lot people didn't even know, it was really hard to see.