It is safer and easier to switch to the alternate breathing apparatus and shut down the leaking one by turning the cylinder valve shut. Using two cylinders (even small ones) and two first stages and two second stages is recommended.
If you have an inline shutoff valve then it could be triggered inadvertently and possibly cause you some extra excitement at depth. Especially if you have big gloves and clumsy hands. An overpressure relief valve would also be needed as stated in the previous post. You do not want a burst hose in case the free flow comes from the first stage.
Feathering the valves is also a lovely method if your kit and your flexibility allow for that.
If the free flow is caused by an ice crystal in the second stage (which is possible due to the moisture in exhaled air - especially if water is near freezing or the surface temperature is extremely cold), then it might even melt after a while and become usable (this has actually happened to me).
My experience is different from that of Tbones, but perhaps we dive in different environtments, with dissimilar gear/gas stations, different type of diving, different type of luck, don't know. Anyway he made a very good point. But in my experience: Almost all the free flows I have seen have been caused by second stage freezing due to moisture build up from exhalations. Very rarely have I seen a first stage free flow, but then again we keep our own cylinders very very dry and take great care in maintaining our compressors. When there is no moisture in the cylinder, then there is nothing that can freeze inside a diaphragm first stage. With rental gear and someone elses compressor (etc etc etc) you don't have this control and risks increase. So sometimes it is out of your control. Could me many more reasons.