Where a vacancy occurs in the office of trustee under the circumstances described in RCW
11.98.039 (1) or (2), the outgoing trustee is discharged upon the agreement of all parties entitled to notice or upon the expiration of thirty days after notice is given of such vacancy as required by the applicable subsection of RCW
11.98.039, whichever occurs first, or if no notice is required under RCW
11.98.039(1), upon the date the vacancy occurs, unless before the effective date of such discharge a petition is filed under RCW
11.98.039(4) regarding the appointment or change of a trustee of the trust. Where a petition is filed under RCW
11.98.039(4) regarding the appointment or change of a trustee, the superior court having jurisdiction may discharge the trustee from the trust and may appoint a successor trustee upon such terms as the court may require.