Hazrat Uqbah bin Aamir (RA) once asked Rasulullah r: “How can one gain salvation?” Rasulullah (Sallallahu Alaihi Wasallam) replied, “Control your tongue, let your house be sufficient for you (don't leave home unnecessarily) and cry over your sins (repent sincerely).” (Tirmizi)
We need to be cautious when in public places and in our association with people. Hazrat Abu Sa'eed Khudri (RA) narrates that Rasulullah (Sallallahu Alaihi Wasallam) said, "Be careful! Avoid sitting on the public roads." The people replied, "There is no way out of it as these are our sitting places where we have talks (due to having small homes)." Rasulullah (Sallallahu Alaihi Wasallam) said, "If you must sit there, then observe the rights of the road." They asked, "What are the rights of the road?" He said, “Lowering your gazes (from what is unlawful), removing harmful things, returning greetings, advocating good and forbidding evil." (Bukhari)
A believer should avoid places and events where ones presence will contribute to the possibility of vice and the implication of sin.