To be a little clearer, are you saying that you have running code now, that is randomly ending up in the bootloader? The three most likely causes are a corrupted stack, a bad pointer-to-function, or hardware transients.
Or are you saying that you want to control entry to the bootloader to prevent it from your application?
That is somewhat dependent on the CPU you are using.