I have a 1999 Impreza 1.6 wagon.  I am having a problem where the vehicle will run for short periods and then shut down.  If you try to restart immediately it will not restart however if you put it down for a while and try restarting it after some hours it restarts and runs for a short while before shutting down again.  Initially the run period would be for a day or two.  Now its is for very short periods, sometimes less than  an hour. The vehicle is a standard street version with no modifications at all.  I recently replaced a knock sensor.  I have had it on the diagnostic machine but no issues show-up. Has anyone experienced this problem and what are the possible solutions..