Pilots routinely train on handling in-flight emergencies: Assess the situation, react, and (above all else) never stop flying the aircraft. There are few mechanical failures that can prevent the pilot from continuing to fly the aircraft. However, add fire, smoke, or another contaminant into the cockpit and the pilot has little chance to save the day.
Source: aopaAircraft Maintenance: Fuel and oil in the cockpit