There needs to be an "approved" gas valve there, AT the appliance NOW. If there isn't one, then one needs to be installed, NOW.
Additionally, some type of "approved" flexible line should be being used at the dryer. These flexible lines have a 45° flare fitting. So the proper male flare fitting should be properly attached to the gas valve. With this proper, required installation, you shut the appliance gas valve off, and detatch the flexible line. Then remove the gas dryer.
Lastly, you have an exposed 45° male flare fitting. You install onto this a 45° female flare cap (blank-off fitting) with a copper seal washer, and tighten it properly. NOW you have a safe, secure and lawful situation. Now it's doubly safe.
I'll look for an online fitting and post a link.
For MY house, I have made an additional aluminum locking structure that is attached to the valve that will not allow the valve handle to be moved from the "closed" position, but that's just me. Now it's triply safe.