Doors.
You're thinking of doors.
Magma-safe doors.
Simple magma plug. Very easy, 100% effective unless you are pressurizing magma. It may or may not stop water though.
Doesn't block movement, stops magma from both sides and the easiest plug you can make.
RRRRRRRRRRRRRRRR z+2
RRRRRR _ RRRRRR z+1
_______^R ^_______ z
RRRRRRRRRRRRRRRR z-1
R being rock, _ being a mined tile, ^ being an upwards ramp, and a blank being empty space.
Combine the two. A door at the top of the "plug" and adjacent to the ramp will be indestructible, because building destroyers can't path to the door. Its a cheap exploit I use occasionally for alternate paths from the outside. Its the same exploit about damaging hatch covers from below.
As long as no one tries to go through it, which is easy to accomplish, magma, even pressurized magma, can't pass. It seals on its own, and if you forbid it is immune to building destroyers. Frankly, you can accomplish this by requiring diagonal access to a door too.
The plug isn't really necessary, dwarves will outrun the magma, so there is no chance of the magma getting to the door at the same time as a dwarf. If the magma is pressurized it will beat the dwarf to the door, and kill him preventing the door from opening. It does however provide a convenient opportunity to abuse the invulnerable door glitch.
You should even be able to add a pressure plate that detects magma to close the door, which remains invulnerable and doesn't require being locked manually.
************************************
Side View
************************************
#######################
########## ┼ ##########
__________/#\___________
#######################
************************************
Top View
************************************
Z2
#######################
########## ┼ ##########
#######################
************************************
Z1
#######################
++++++++++^#^++++++++++
#######################
************************************
Legend
************************************
Floor: + _
Wall: #
Ramp: / \ ^
Door: ┼
************************************