We report the development of an invertible wavefront switching system, consisting of a spatial light modulator (SLM), a diffuser, a signal beam, and a control beam. The shaped optical signal beam can be switched between on and off states by disturbing the diffuser with a control beam via thermo-optic effect. During the wavefront shaping process, the extinction ratio of the signal beam is iteratively optimized. We demonstrate a high extinction ratio of nearly 20. In addition, when the control beam is on, a switch with either on or off state can be configured to via encoding different wavefront patterns to the signal beam. This work potentially advances many physical or bio-medical applications employing all-optical switches.