Clock switching hangs when switching back to original source
If you meant to set those bits as binary, you need to change this:

OSCCONbits.NOSC = 000;


to this:

OSCCONbits.NOSC = 0b000;


Also wherever you set NOSC back, it should be set to 0b011 not just 011.

A prefix of "0" actually makes the value octal in the XC32 compiler (as pointed out by @Lundin in comments), which is decimal 9, which == 0b1001, so this is certainly one problem that needs fixing.

Also, in the PIC32 Peripheral Library Guide it says:

"In general when switching to a higher CPU clock frequency the Peripheral Bus divisor should be set to the new lower value before changing the CPU frequency"

So, when going up/down speeds, you should be using the appropriate order of the following calls:

OSCConfig(OSC_FRC, 0, 0, OSC_FRC_POST_1);
mOSCSetPBDIV(OSC_PB_DIV_1);