PIC16 only runs on debugger
This is most likely due to the watchdog timer (WDT) resetting your chip. The WDT is enabled by default in all PICs, so you must explicitly disable it if you don't have specific instructions in your code to clear the timer. See section 9 in your datasheet for more information about the WDT.

The WDT is configured in the CONFIG1 register, so it will become part of your "__config CONFIG1" line of code.

The screenshot below is from the datasheet showing the CONFIG1 register. Notice the default values for WDTE are \$11_2\$, which corresponds to "WDT Enabled".