Attitude and Patience Problem

My boyfriend and I have been dating for around 6 months, but we’ve know each other for a while. I really like this guy and his family (he’s my best friends cousin so I’ve known them for around 8 years). Recently, I’ve had a really big attitude with him and have become very defensive with any advice or criticism he may give me. Also, he is going through ALOT (and when I say a lot I mean ALOT) and has been really edgy. But what I’m implying is that how do I get to a calm state of mind if I feel myself getting an attitude or become impatient/rude? I don’t wanna ruin this relationship over something like this (in the past this has Happend too and I can’t do it again 😪)