An instructor did this once with me at a safe altitude and we could've landed easily at a huge military runway below. We did it only for a short time. The learning experience was that, in a Piper Tomahawk, it takes as long as 40 seconds from fuel shutoff to engine-out and the vertical speed will decrease from 900ft/min to 1000ft/min, compared to an idling engine. With the delay beeing that long I do believe that a pilot can forget about it if the workload is high. I learned from it that I only switch tanks if I have a minute to keep an eye on the engine. Also, conrtary to a post above, the engine doesn't sputter. After 40 seconds of cruise power it simply became silent within a second or two.
I think my instructor showed good airmanship with the decision making: the military airfield, altitude et cetera. The flight was safe.

With the wrong instructor, of course, it could be dangerous.