The reason your problem is intermittent is because your engine will stop at different angles. When the engine stops on the spot where your flywheel's ring gear is worn, you get the grinding noise. If it were the starter gear, it would do it all the time.
If the car is a manual transmission, you can use a slight grade to have the drive wheels turn the engine enough to get you to a spot where the teeth are good. Just a little nudge is usually all it needs.