"He won't let me leave." It's not HIS decision, it's YOURS.
I will tell you this, if you do deliver this baby it will always be your baby. How long will he be your boyfriend? Are you in love with him or "comfortable" with him? If he's calling you stupid and telling you not to leave it tells me he is afraid. No offense intended to you but why are you with a 40 year old anyways? He literally could be your father. There are lots of other men out there, your age, that would love to have a relationship - baby or no.
You can raise a child on your own, a lot of women do. Don't stick around just because of that. He can pay child support and have visitation, and make darn sure it is enforced.
Regardless of your decision, one of you needs to start using birth control.