By the discharge of a contract is meant the termination of all liabilities thereunder, in whatever way this may have been brought about. Such discharge may take place either by the act of the parties or by operation of law. A contract may be discharged by act of the parties either by its performance according to the terms of the original contract, or by an agreement between the parties releasing each other, or releasing the party who has not performed his part of the contract, or by the substitution of a new contract.