Leaving the airport during a layover without a visa is a violation of airport policy. Nevertheless, if you just want to get through customs and onto the next flight, you won't need a visa. In short, if you have a valid visa for the nation you are visiting, it is safe to leave the airport upon arrival.