Well, it sounds to me like you have to immediately address it while it is still fresh in your mind. However, you would do the right thing by moving away from your D before doing it. Maybe ask him to go outside?
If he is that depressed, then he needs to know you care also. And you walking away when he is feeling such strong feelings is only telling him he doesn't matter to you - then you come back later and yell at him over it. I totally understand - although I used to do more of what you do and let it fester. It was hard to learn not to.