Buck-Boost troubles: 5v output becomes 20v+ if input drops below 3.5v

If you can take a look at the output, it sounds like it is oscillating badly. It also sounds like the load is an inductive load. Adding some bulk capacitance on the input and outputs will probably help, High frequency bypass would not hurt either.