These are, in fact, the times to lean on God the most. He already knows what's on your mind, regardless if you're acknowledging His presence or not. He's not like a parent that you have to try and please with happy thoughts and words ("don't say 'crap' in front of your mother," and the like). Despite my impurity, he still sticks around and moreover, cares for me. There is no pride in hiding impure thoughts from God--no pride and as I've discovered, no sensible rationale (for there is such a thing as insensible rationale, you know). Because of this, it's not only possible, but helpful to lean on God.
He already knows.
Instead of trying to take it away on my own before I can talk to God, I vent it to him. Or even just focusing on him can take my mind off the sin/hurt.
I don't think prayer has to be with your hands folded and your eyes closed. It's not a "to do list" that you make during the day and that you run through before you go to bed. The mere fact that it was thought to be put on the list was a prayer in itself. Why not take the 20 seconds after you thought about it, and turn it into a quick prayer? Instead we try to figure out how we'll remember to do it later, before bed. But after you've brushed your teeth, washed your face, and flossed. And read. And had a midnight snack because you're jet lagged. And brushed again. And flossed again.
Sending my thoughts to God in this way (in a frequent and somewhat unritualistic and informal manner) has been helpful for me. Leaning on him on a daily basis admittedly, sounds a bit cliche, but it's helpful imagery for me. Not being ashamed of my worst (not to be confused with accepting my worst as 'okay'), and knowing that it's part of being human is nice. Taking my worst to God and realizing that he can help, is refreshing.
When else can we lean on God?
During the good, of course. But we don't feel like we need his support then. Because things are good, and we can run around fine on our own two feet. But when we've "sprang our dignity" (to quote Madeleine L'Engle), we come desperately hobbling. I have to remind myself from time to time, that I wasn't put in these good situations by my own accord. I don't know why I was born into this life, but it's a good one, and I have God to thank for it.