Why does my iphone 4S hangs up calls if I lock the screen?

I have noticed my iphone 4s hangs up calls if screen is locked and the thing is it does it pretty randomly. So sometimes it hangs up while other times it won't.
Today I made a call and locked the screen and nothing happened so the call was maintained but a few minutes ago, I received a call but locking the screen ended the call. So I called the person back and tried again, the call was ended again.
Does anyone know what the problem is?
Any help is appreciated.

I'm pretty sure the iPhone is supposed to hang up calls upon locking the screen, that's how it's designed. Why do you want to? It has a proximity sensor.

Pressing the lock button (at the top of the phone) is the end call button while you're in a call. If you want the screen to go off, put it to your ear. It detects when something is nearby (your ear) and locks the device. When you move the phone away from your ear it unlocks again.