If the contract is ab-initio void ,then there is no need to cancel the agreement. Only You've to see, Whether the agreement has been mutated or not? And If it is wrongfully mutated , then only You've to go for an application for cancellation the same to the S.R. as well as a complaint for fraud & criminal misrepresentation.
When the deed itself is cancelled by both the parties to the same as RAVI said there is no question of capital gains and so far as refund of stamp duty is concerned there will be no refund of the same. Moreover they have to pay addtional charges to ratify the entry already made by the registrar.