Actually it is a feature that has been in at least iOS 4 and was carried over to iOS 5. I can't verify iOS 3 or older because I have only been on the iPhone since April.
If your phone was locked when you answer a call and if the other person hangs up first, your phone will automatically return to the previous locked state. The reason for this is because the iPhone always tries to return to the state it was last in before the call was received.
Now if you dial out, the last state is the dial app and hence you will be returned to it when the conversation is over.
So if you want to hang up first, you have to be quicker than the other person
