PIC24 bootloader writing the config bits
The Microchip bootloader code likely is erasing the entire Flash region before programming. If you don't program the config bits before reset, they will be left at 0xFF which is quite unlikely what you wanted.

Either modify the bootloader to avoid erasing the final page of Flash, or make sure you re-apply the necessary config after erasing.