What is the purpose of the fuel shutoff valve?
It's both a maintenance and safety feature.

You need a way to cut off fuel flow to the engine compartment, either to work on the engine, or because of a fire at the engine, or because you are doing a forced landing and it helps reduce the risk of your entire fuel contents seeping onto your hot engine if you bend things a bit putting it down and a fuel line gets broken.  

So you will always have a shutoff valve, and it's always somewhere upstream of the firewall.