Answer in Details
Shiva himself often retreated into solitude (vairagya) to seek inner peace and higher consciousness. Leaving a harmful environment is permissible if it aids in maintaining one’s spiritual and mental well-being. However, before taking such a step, one should try to resolve conflicts through patience, compassion, and communication, embodying Shiva’s qualities of forgiveness and endurance. If all efforts fail and the environment hampers your spiritual progress and peace, seeking a peaceful and safe place is justified according to Shiva’s teachings.
Ultimately, listen to your inner self (Atma), remain detached from worldly attachments when necessary, and seek the path that leads you towards peace, self-realization, and devotion (bhakti) to Shiva.