Controllable freezing of the nuclear spin bath in a single-atom spin qubit