If you continue to run the engine, the original cause of the fire may reiginite it -- or the embers may not be completly out, etc.
I'd speculate that the most likely causes of fires in (diesel) engine comparments on sailboats is i) electrical short in primary power to/from batteries, starter, or alternator, ii) locked-up sheave or alternator cause a belt to burn, iii) some other piece of equiment that you have living in there.
In some dreadful situations where your concern is less from fire and just getting the boat to move somewhat farther (regardless of the fire) -- then you would want to be able to override the shutdown. Otherwise, you really need to reduce the flow of air into the space, even if you don't have a dedicated automatic extinguisher system.
If you are concerned about this, you might consider an audible alarm with manual fire extinguisher deployment.