This situation is known as Agoraphobia where the person feels he or she will not be able to survive in closed places because of some unfortunate health issues. It can be seen in crowded or closed spaces such as lifts, bus, train, market, closed room with minimal ventilation. The person feels he or she will die because of lack of ventilation or because of difficulty to reach at a nearby hospital.
Next Steps
If it's affecting your day to day life You should consult a Psychiatrist offline or online whenever possible.
Health Tips
It's the fear that causes this feeling of Panic. Sometimes it may present as fear of getting a heart attack also but when we check the ECG it will be normal.
I hope this helps
Regards
Dr Parth A Soni - Psychiatrist