Configure UCSCTL0 register MSP430F5529
According to the MSP430F5529 datasheet, this MCU supports "up to 25-MHz System Clock" rate. Consequently, achieving 39 MHz stable operation is not possible.

On msp430, it's often possible to write DCO configuration values in the registers that are out of the range of the MCU capabilities. Looks like this is what's happening here.

Try setting UCSCTL1 to DCORSEL_4. That should give MCU clock speed in range from 12 to 28 MHz according to the datasheet.