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 :)
Companies are free to terminate the contract of contractors according to the agreement within the contract.
If the contract allows early termination, the can terminate the contract early. Even if they contract does not allow it, they are still able to. It would be then up to you to take this breach of contract to court.
If there is an agreement in the contract that the contract timeframe would last a period of time, then you could make an argument that you suffered a loss due to beach of contract. What may be more palatable to all parties is to meet somewhere in the middle to avoid protracted proceedings.
If you are a contractor, you would do well to understand your legal and contractual rights as you often are less protected by law than regular employees. However, there are some jurisdictions that may give certain legal rights to contractors.