It's perfectly possible to brake safely while leaned over, and to do so without the bike straightening up; but you have to practice doing this before that sudden emergency pops up (if it's not second nature, it's not going to happen when you most need it). The trick is to countersteer as you brake so that the bike remains balanced at the same angle as before you applied the brakes.
You practice this by finding an empty road and applying the front brake gently and smoothly as you go around the curves. After you've done it for a while you will find that you begin to automatically add more lean as you add more brake. When it begins to feel more natural, start hitting the brakes a bit harder and faster until you can bring the speed down quickly without the bike suddenly heading straight for the outside guard rail.
Note that there are times and places where trail braking can put you on your head: If you are already at full lean, suddenly hitting the brakes will probably cause a lowside, and so can hitting a patch of frost or moisture.
On the other hand, trail braking can save your bacon. Should you happen to come around a blind corner to find the road full of spinning cars and a motor home sideways across both lanes, this technique could come in handy, if you had practiced it in advance.
Definition of Trail Braking
Trail Braking is the term generally used any time you're braking and turning at the same time. Sure, you mostly begin braking in corners on the track, but we're speaking about street riding where the odds say one day you will have to pull an emergency stop in mid-corner. (And besides, there's no reason a track technique can't be used on the street as well.)
Any sort of hard braking in a corner will cause your bike to straighten up; it's simply a matter of inertia and how hard you brake. (When you apply the brakes in a turn you're changing the vector of the bike's inertia. The inertia of your forward motion has to go somewhere when you brake, and that "somewhere" is outwards.)
When you use the rear brake to set up for a corner at racing speeds, you're usually doing it to swing the rear end outwards like a dirt biker and "back it in" to the corner. That doesn't really qualify as trail-braking because you're off the brake once the turn-in is established, and it isn't something you'd normally do on a Ninja 250 anyway; there simply isn't enough power on tap to establish and control the resulting power slide.
Trail braking: Why and How
A lot people think that you shouldn't brake into, or while you're in, corners. In fact, braking into corners is called "trail braking" and it's a very important survival skill for street riding, not just a track technique used by racers.
You will hear people say that you shouldn't brake in corners for three reasons:
(A) The harder you brake, the more your bike will want to straighten up and go off the outside of the corner.
(B) Your bike has less traction under braking and might lowside or highside.
(C) The fastest way through a given corner is usually to brake before the turn-in and then accelerate through the corner.
And all three of the above are true, providing that you realise that there's a great big "BUT" attached to each and every one of them.
(A) Would be true, but what you do when trail braking is counteract the bike's urge to straighten up by countersteering more deeply into the turn at the same time that you brake. The harder you're braking, the more deeply you lean in response, and this balancing act must be automatic and instinctive, so you don't have to think about what you're doing while you're doing it. In this way it's possible to brake very hard while turning and still maintain your chosen line.
(B) Is always true, but you're not supposed to be all that close to the edge of traction when you're riding on the street, and unless you run across a patch of gravel (which you should have seen well before you got there) or are riding way too fast, there is generally plenty of traction reserve to play with when you're trail braking. This does not mean that you can suddenly slam on the brakes in a corner and expect that bad things won't happen. As with all control applications on a motorcycle, the brakes must be applied smoothly and progressively to give the bike (and yourself) time to react to the transient changes in balance.
(C) Is usually (not always) true under racing conditions, but on the street we aren't usually concerned with the fastest way around a corner. We have to be concerned with things such as oncoming trucks or other road conditions that are seldom found on racetracks, and survival takes precedence over speed.
"So okay", I hear you say, "You've demonstrated that controlled trail braking is perfectly possible, but why should I want to do it?"
Simple: Because trail braking is the only way to get stopped while you're going around a turn, and sooner or later you're going to come around a blind corner and find something that makes you want to stop very badly and just as quickly as possible. It could be a bear in the road, or an unexpected washout, or oncoming traffic, or a mudslide, or a fallen tree, or a bleeping UFO, but some day there WILL be something there, and if you don't know how to trail brake you're going to either hit it or go off the road.
Now, the way you get good at trail braking is to practise it over and over again on clean dry curves that have complete visibility all the way through, with no other traffic around, and under non-emergency conditions. You start by applying just a taste of brakes as you go around said curves, and finding out just how much countersteering you must add to balance that amount of brake pressure and still maintain the same line through the turn. (Be ready for the bike to fall inwards a bit as you get off of the brakes, and remember to accelerate to balance it out as you exit the turn. You might have to steer a bit as well.) Once you become comfortable with light amounts of braking, you're ready to begin increasing both your braking effort and your lean angle until the whole procedure becomes second nature to you at any degree of braking pressure.
Can you get hurt by braking in a turn? Yes. Particularly if you do it incorrectly. But you can also be hurt very badly by not knowing how to trail brake when it's the one technique that could have pulled your bacon out of the fire just before that big "crunch".
In short, trail braking is just one more riding technique that a good motorcyclist adds to their tool bag as they go along. Saying "Well, I'm not going to use that particular tool" is like a mechanic saying "Well, I'll use a hammer and a screwdriver, but I won't use a wrench". As we all know, it wouldn't be very long before said mechanic ran into a situation where he really needed to tighten down a bolt, and his hammer and screwdriver would leave him up the creek without, um, a wrench. Ask yourself if you would truly want that guy to work on your bike...