It's the other cat outside that's stressing him out. Afterall, it's HIS territory, yet he's closed up inside.That's VERY stressful. And since you're the first closest thing to take out his anger on, you're it! I suggest a squirt bottle. Once he knows he gets wet everytime he does that, he'll get the idea.

Good luck.