Losing his erection

So lately in the middle of sex my boyfriend will lose his erection but it only happens when he is on top. At first this never happened and sex was fulfilling but it really started to bother me and I started getting mad at him cause he acted like he didn't want to tell me what was going on.