Section 51. At least five days prior to the sale or transfer, otherwise than in the ordinary course of business, of all or substantially all of the assets situated in the commonwealth of a business corporation as defined in section 30 of chapter 63, except in cases where a waiver shall be given as hereinafter provided, the corporation or any person in interest shall notify the commissioner in writing of the proposed sale or transfer, and of the price, terms and conditions thereof, and of the character and location of the assets and cause to be filed with the commissioner all such tax returns as may be necessary to determine the taxes due and to become due and payable to the commonwealth to and including the date of such sale or transfer, and shall pay to the commonwealth all such taxes owing to said date of sale or transfer. At the time of any such sale or transfer, except in cases where a waiver shall have been given such taxes shall thereupon become due and payable. In the event of a failure to notify the commissioner and so to file such return or returns and pay such taxes at or before the time of such sale or transfer, the commonwealth shall have for its exclusive benefit a lien upon all of the assets of the corporation in the commonwealth effective immediately prior to such sale or transfer to the extent necessary to satisfy said taxes. Said lien shall terminate not later than three years after the date of said sale or transfer and until such termination may be enforced under and in accordance with the provisions of chapter two hundred and fifty-four in the case of real estate and sections fifty-three to sixty-four of this chapter in the case of personal property, but the ten-day notice provided in said section fifty-three shall not be applicable to this section. Prior to and after the date of such sale or transfer, the commissioner may waive such lien and any or all of the other requirements of this section. Such waiver shall be in writing and shall constitute final and conclusive evidence as to any person other than the corporation that said lien has not arisen or has terminated, and it may be recorded with the appropriate register of deeds or city or town clerk as the case may be, and the said register, city or town clerk shall receive the same upon the payment of the fee prescribed by law. This section shall not apply to sales or transfers by receivers, assignees under a voluntary assignment for the benefit of creditors, trustees in bankruptcy, or public officers acting under judicial process. This section shall apply to transfers hereafter made as security for the performance of an obligation which is not incurred in good faith by the corporation for the purposes of its business but otherwise shall not apply to transfers by way of security.