Why does engine cut off after idling for awhile?

Those stupid little magic cans have tripped me up a time or two. If they are not grounded they don't work. And neither will the engine run. Yet they can run for a million miles when they feel like it,lol.