If it's what happened to me it was ignition coils and I also changed my spark plugs at the same time. Also, when I've had some engine noises/weirdness - bad gas, forgot to clean MAF after changing air filter, did not completely close engine oil cap after changing oil (letting extra air into engine), accidentally knocked the hose connection loose on the air filter housing when adding coolant have all caused some problems with idling or engine sounds.
I think only the ignition coils/spark plugs and the engine oil cap made it turn off. The other accidents just made it idle high or or rough, etc. Bad gas made it knock.