How to cap and remove fireplace gas pipe?
You have the right idea. Just remove the flexible pipe and transfer your cap to the fitting on the shutoff valve.


Make sure you leave the shutoff valve in the off position.
Make sure you have the correct threads and seal them and the connection is tight. 
Check for leaks with a thick solution of soapy water.
If at any time you feel uncomfortable or think things are not working out right then shut off the outside valve and call a pipe fitter. 


Good luck!