You mention this happening more often when climbing. Assuming you are seated:
1 Try moving the seat back a little.(just 1cm)
2 If you have an easier gear available, use it. (try not to mash as much to get through the pedal stroke)
3 consider a Q-Ring for the front chainring.
Balance is the key to efficiency