If you've got steel, iron, or pig iron bars, you can install them as "vertical bars" in a lava tunnel to prevent imps and magma men and whatnot from getting through. If you have ample bauxite, you can use a masonry shop to build a bauxite grate with the same effect (except you have to install it as a "wall grate"). Any other material will melt when the lava flows through it.
If you've got bauxite, you can also make bauxite doors or floodgates and bauxite mechanisms to more easily control your magma flows. You can use steel or iron doors and floodgates as well, but bauxite's much cheaper. Getting your masonry and mechanic shops to use bauxite instead of the other sorts of rock can be a bit of a pain, though. I usually create a room with a bauxite stockpile, masonry shop, and mechanic shop with a lockable door, and then lock my mason/mechanic inside until he's completed the special orders. Then I forbid the workshops and forget about them until I need more bauxite stuff.
If you have no bauxite, or if something's gone awry and you flooded a place with uncontrolled magma, you can also get your dwarves to dump water on it by digging a channel over it and designating it a "pond". Note that the water has to fall at least 1 z level, otherwise it evaporates without also freezing the magma in the process.
Magma's very handy if you want to do metalworking of any sort, or if you've got sand on your map and would like to try your hand at glassmaking.