The easiest way to find a taxi late at night is at an approved taxi rank - found outside major hotels, train stations etc. Learn where they are in your area and go and stand by one rather than wandering around aimlessly looking. Always make sure it looks like a London cab, or a normal car painted in your town's official taxi colours. In Leeds for example taxis must be painted with white sides and a black hood and boot. Other towns they may be painted green or yellow. It should also have a taxi light on the roof or dashboard. As well as a meter for the fare. Any other kind of taxi - officially known as mini cabs, are not allowed to pick you up from taxi ranks, and always have to be booked in advance over the phone or at the office/base.
Alternatively learn where the mini cab booking offices are located in the area and go there and ask for one. By Law they have to record the booking and the driver assigned, which will help if you need to go to the Police later.
You can always phone your favourite firm but make sure you get in the right cab, not the first car that pulls up, ask what firm they are with, or look for a company logo somewhere.
When you get in make sure you can see the taxi licence number, usually found on the passenger side of the front window. No licence, get straight out as soon as you can.
Basically problems occur when you wander around drunk and get in the first car that looks like a cab, which is not something you'd ever consider doing sober.
Apart from the danger of rape or mugging, if you get into a minicab - even a reputable one that you use all the time, without making an advance booking, then their taxi insurance is invalidated so if you are in a crash, you won't get a penny.
Any driver driving around with the window down asking people if they want a taxi can't be any good. If he was a decent cabby he'd work for a reputable firm that was snowed under with advance bookings. So either he's working for a firm that noone books, which is not a good sign, or he isn't a taxi driver at all, which is even a worse sign.
It's common sense really, apart from the safety implications, getting into any old car means you won't know which firm to phone if you leave your keys or phone etc, on the back seat.