Had that one over the summer. Chain skipped out of the bottom gear halfway up a brutal 18% incline. Struggling to unclip and maintain momentum I had just enough strength to get to the side of the lane before grinding to a halt and timber! Falling slowly sideways onto the grass verge.Realised that once and found an extra milligram of strength to make it to the top of the climb having realised that just the attempting to unclip could result in the bike ceasing all forward motion and and gain a quick motion to the horizontal.
In answer to the OPs original question: I find it really useful to concentrate on keeping my breathing under control. It's easy to start panting as you struggle up a hill and that uses up a lot of energy in itself. Concentrating on taking deep steady breaths keeps the heart rate down and takes your mind off the climb. If I feel my legs tiring I'll also start thinking about pulling my pedals up rather than pushing them round or shift my weight back a bit in the saddle. I'm not if these last things make any real difference in terms of energy use or anything but all the time your thinking about them your climbing the hill without thinking, "I'm dying! I'm never going to make it up this *@$#%in' hill!"