A little more detail for the unwary:
Prepare a path to the magma that is above the tube that you intend to fill with magma. Note that magma flows fairly slowly after its initial burst out of the pipe; you don't have to worry too much about it reaching your fort quickly, but you'll want the tube prepared before you breach the pipe.
What needs to be prepped in the tube? Well, the magma pipe has such Fun creatures as fire imps. Physically they're pushovers - I've seen them killed by single dogs - but they breathe fire and will swim up your magma tube, coming out in your nifty little magma forges to kill all your craftsdwarves. To prevent this, make sure that your magma tube is blocked up with grates, bars, or fortified walls (all of which I'll refer to as strainers from here on out). These can be constructed from any material, by the way; once built, they can't be destroyed by the magma unless you try to do tricks with them (hook them up to levers, etc - not important right now). Strainers allow the magma to flow unimpeded, but of the creatures that come with magma, only the harmless fire snakes can pass through them.
I usually put at least two rows of strainers between my fort and the magma pool because of a bug: the magma flow can push a creature through the strainer, even if the creature couldn't normally fit. It's happened to me a couple times, but not often.
Anyway, once the tube is prepped, then use the upper path to channel out the final square that separates the tube from the rest of the pipe. The magma will never flow uphill if you don't pump it there, so the upper path is safe for your dwarf - except for one thing. There's now access in that upper path for the nasties of the magma pipe. Seal that off with a constructed wall and you should be golden.