I would recommend you talk with your son about going out his window onto the roof now that he has calmed down and point out the risks and how much you love him and don't want to see him get hurt. Explain an alternative would be to open the window and shout at his cousin or wait till his cousin comes inside. If he goes out on the roof again, I would immediately insist he come in. If it becomes a recurring issue I would even consider putting a guard on the window to prevent him from opening it. I would also consider a serious consequence later (not to be discussed while he is in anger overload) that is tied specifically to this kind of dangerous behavior.
At other times when your son is not in danger, I would recommend not talking to your son while he is in anger overload. You can always have a consequence later if he threatens to punch you again, but if you talk about it while he is agitated, his outburst is likely to go on.
It is good that you are beginning to look for patterns: you mention it happens more with you and the cousin. Continue to note the triggers, and then see if you can plan around them sometimes. For example, if you know helping him with homework sometimes triggers his rage, then take a break when he starts to get upset, walk away, and help him some more later. It may be preferable for him to get a wrong answer to having a melt down. Also if you walk away he will see that if he mistreats you he loses your attention. Then pay attention to him when he calms down. If you have a consequence for his threats or lies, talk about that later when everyone is calm.
I will let you know when my parent's manual is ready in a couple of months so that you can work on some other strategies for anger overload with your son,
David Gottlieb, Ph.D.