What happens if Solar Impulse II encounters un-expected head wind and runs out of battery power?
Solar Impulse has two means to store energy: Batteries and altitude. Weather permitting, both will be fully charged at sunset, and mostly depleted over the night. The rate of depletion at sunrise depends only on the time between sunset and sunrise, not on the direction and strength of the wind.

Headwind only means that less ground is covered. Solar Impulse is optimized to fly at a certain speed and will not fly much faster or slower, regardless of wind. If the wind is strong enough, it will simply not cover any ground but be blown back. But the wind will not cause the batteries to be depleted earlier, and the next day they will be recharged if the sky is clear.

Wind speed and direction vary with altitude, so the aircraft might well overcome a wind that had prevented it to make any progress the night before by flying at a different altitude the next day. After all, flight duration is limited by the pilot, not the power source.