“Illegal” and “in violation of a contract” are completely different legal concepts. The parties are free to violate a contract at any time as long as they accept the penalty that is provided for in the contract. Illegal means you broke a criminal law.