An agreement by a husband, wife, father, or mother shall not take away or restrict any of the liabilities of the husband, wife, father, or mother under this Act in respect of the maintenance of a person, or affect the operation of a maintenance order against the husband, wife, father, or mother, or the right of the court to make any such order, but the court may, having regard to the existence of the agreement and to all the circumstances of the case, refuse to make any such order.