Confused

Hi everyone I’m 21 (female )and a few years ago I dating a lad who lived in a hostel, I wasn’t allowed to be there and I stayed the night . So in the morning when I was getting ready to leave he said I had to have sex with him in order to leave other wise he would let me walk out and get caught and get in Trouble and that the police would be called to.

Basically if I didn’t have sex with him I couldn’t leave because I was scared of getting caught and getting I’m serious trouble

Is that rape? To make me think I didn’t have another choice I’m confused I’ve thought about it over the years .. he also done a ton of other stuff to me.

I need help I don’t know what to do that and other things have made me depressed I’m at the point now where I question if my life is worth living. Please comment back and let me know. I need to make changes and get answers