Stoop is not correct - it works like this. I am going to simplify it for the sake of example and assume a flat rate of tax of 22% rather than the actual sliding scale starting at 10% - but the basis will be correct.
Assume an annual salary of £20,000 with an annual tax allowance of £5,000 - this would mean that tax is payable on £15,000 - and the tax man, via the Notice of Coding PAYE system will collect the same each month (You don't earn the tax free bit first and then pay tax on every penny).
So - £20,000 monthly = £1,666.67
Tax free amount (in this example) £5,000pa = £416.67
Tax payable monthly on £1,666.67 less £416.67 = £1,250.00
£1,250.00 at 22% = £275 tax paid per month.
If you stop working 6 months into the tax year you will have paid £275.00 x 6 = £1,650 ..... B U T .... you have only earned £10.000.
The correct amount of tax due is £10,000 earned less £5,000 tax allowance = £5,000 taxable at 22% = £1,100.
£1,650 tax has been paid but only £1,100 tax is due - This person can claim back £550.
It does not matter when in the year you stop working as if you earn less than you have been taxed on you are due a refund.
I hope this clarifies the situation - as I said it is more complicated than this but these are the basics.
Now my brain hurts.
Dave Nicholson