Albuterol
Albuterol can often keep these things from happening.  Often, people with diseases like asthma or COPD are prescribed albuterol inhalers.    As soon as they start having trouble breathing, they can use the inhaler to breathe albuterol right into their lungs.  The albuterol will stop the bronchi from getting narrower, and will make them wider again.  This makes it possible for normal amounts of oxygen to get to the lungs.