Suppose a person is doing an incredible job at work (e.g. being very productive and coming up with innovative ideas). Let's assume that this person is a contractor for this company. Are there cases where the company can terminate contractors because they expected them to work at a slower place? For example, it was expected that the contractor was to complete the project in 6 months but instead he completed it in 3 months. Is this a valid reason to terminate a contractor (maybe due to budget constraints, no more project available, etc.)?
Most contracts have termination clauses in them where either party can terminate at any time with a given notice period. If the work is done, then that could well be a reason to terminate early. Read your contract, that's the best way to see what you agreed to with regards to early termination.
From a comment by the OP:
The contract was for 6 months but was terminated in 3 months. I am assuming that this was because all the work was done combined with lack of projects, billing issues, etc. Also why would companies hire contractors instead of full time employees?
Usually, companies hire contractors when there is a specific unit of work that needs to be done and they don't need or want to keep those resources around afterward. Sometimes the project takes longer than expected, sometimes shorter. That's just how it works as a contractor, you're quite literally a temporary resource.
Don't think of early termination of a contract as necessarily something you've done wrong. Ask if you can use them as a reference (given you finished everything well before planned) and move on :)
If you have a six month contract, then the company and you both planned that you will do a task taking six months. If it is done in three months, then the contract can be cancelled. If after three months you both believe the task will take nine months, the contract can be extended. One side can cancel the contract against the wishes of the other side, but both sides must agree to extend the contract. On the other hand, if you did task A in 3 instead of 6 months, the company may be quite willing to give you another contract for some task B.
In the UK, to avoid expensive tax complications, it is very very much recommended that the contract is for performing a specific task, and that the contract length is just everyone's best estimate how long that task will take.