Does a plane have brakes to stop or slow down while flying?
An airplane can slow down and reduce its speed while in flight. The easiest way to do so is to reduce the amount of thrust that the engines are producing. This will produce an almost immediate reduction of the airspeed, especially if the plane is maintaining the same altitude. 

There are also devices called air brakes and spoilers that can be further used to reduce speed. These, however, are never1 used in normal, level flight by passenger2 aircraft and are normally only used to reduce speed during the descent and landing phases of the aircraft3.  

If an airplane reduces its speed too much, it will of course stall and start dropping precipitously, at which time the airspeed usually also increases again. The slowest speed an aircraft can maintain at a given altitude without stalling is listed in its flight envelope.

However in the scenario you mentioned (obstacles ahead), it's usually easiest to simply fly around the obstacle.



1: Never say never on the internet. 

2: The situation is different in military aircrafts, you can see the approaching Su-27 using its airbrake in this video

3: The wheels of most aircraft also have brakes, similar to those found on automobiles. Obviously these can only be used when the plane is touching the ground. Lowering retracted landing gear will also increase drag. There are also thrust reversers on some aircraft that are used in the final stages of landing. Use of thrust reversers during flight can be disastrous although some older aircraft (including the C-17A) were designed to use thrust reversal to scrub speed in-flight.

Finally, some gliders and larger aircraft have drag or drogue parachutes to help slow them down, for example for use on short runways.