had a similar issue with my 5v 2.8 car, would occasionally die at idle, was an issue with the secondary air pump. it started out only happening when the car was cold but eventually would just do it whenever, also occasionally caused an erratic idle and a difficult start. on the base v6 they're located near the generator on the bottom front right of the engine but i'm not sure where yours might be (if it even has one) since the twin turbo motor's plumbing is way different.
this is what they look like
https://www.amazon.com/Secondary-Injection-Beetle-Cabrio-Passat/dp/B06WVCYCVT
don't buy a new one though because junkyards practically give them away.
maybe check the throttle body as well, i also had a similar issue with my porsche but that was the fault of the throttle cable being too tight thus not letting the car click into idle mode but i'm pretty sure the s4 is throttle by wire so i can't imagine it being something that simple...