Ive had several problems with cancelling contracts with o2 in the past. The terms and conditions state that you MUST give 30days written notice when cancelling the contract - UNLESS you switch your contract to pay as you go.
Apparently all calls to O2 are recorded so if you were told one thing then O2 should be able to find it. However, when taking out the contract you would have been given a printed copy which should clearly state the end of the contract period.
If you were told one thing and then O2 went back on it, get writing to the complaints department asap (the address should be on the back of your bill). Ive done that in the past and always got a cheque back! Takes a couple of months for the complaint to be processed thou!
HOWEVER! check the amount on the cheque carefully! O2, sent me a cheque for 30p more than they should have and they black listed me! Didnt find out until I applied for a credit card!
I still keep going back to o2 thou.... my girlfriend is on o2 and wont change networks so im stuck!
Anyway, hope that helps!