It's hard to say for sure based on exactly when it occurs, but normally the common parts consistently associated with a bouncing idle are the Idle control valve, fuel breather valve, and the throttle actuators. Identifying exactly which one might fix your issue can be difficult, but since you said removing the gas cap has made the car stall, maybe start with the fuel breather valve since it's the easiest and cheapest part to replace. Depending on how many miles your car has could help narrow it down further, it's just impossible for anyone to really diagnose anything sight-unseen on the internet.
Here are few threads for you to read through for the ICV and Fuel Breather Valve replacement.
Fuel Breather Valve:
https://www.m3post.com/forums/showthread.php?t=1273927
Idle Control Valve (Device)
https://www.m3post.com/forums/showthread.php?t=842102