Disabling USB

Does anyone know the easiest way to disable USB? I have a bootloader which makes use of the usbh to download a program from a usb flash drive to flash and then runs the program. The program also makes use of usb though so I need to disable it before loading my program. I've called the USBH_DeInit command but that doesn't seem to have done the trick. Is there anything else I've missed?

" The program also makes use of usb though so I need to disable it before loading my program."
"Is there anything else I've missed?"
Yes, if you are transfering from one program to another and want to have USB in the new program - you have to force a 'soft disconnect' on the USB.

My program code seems to be running into issues when it calls the BSP_Delay() function. Is there something I'm maybe missing that I should be disabling to make sure that that works after the bootloader? I did the soft disconnect you suggested but it doesn't seem to have helped

"My program code seems to be running into issues when it calls the BSP_Delay() function."
No idea what that is.

"I'm maybe missing that I should be disabling to make sure that that
works after the bootloader? I did the soft disconnect you suggested but
it doesn't seem to have helped"
Sorry, should have made it clearer.

Disable interrupts and then do the USB soft-disconnect (or the IRQ will start the USB enumeration again in the bootloader just as you are switching to the application).

In summary :
In bootloader, just before switching to application
disable interrupts
do USB soft disconnect
switch to application.