If you are in immediate risk of harming yourself or someone else, the best course of action is to call "911" (if you are in the U.S. or Canada) or go to the emergency room of the nearest hospital immediately. This is the best way to keep yourself safe until any urges have passed.
If you think a loved one is suicidal or planning to harm someone else, you can do the same thing: call "911" or, if possible, take your loved one to an emergency room.
If you are not at immediate risk but are having suicidal thoughts, crisis hotlines (such as the National Suicide Prevention Hotline) are available to help you talk through what you are going through. The most important thing is that you seek help without delay.
If you have a therapist or other mental health professional that you work with, you may already have a safety plan in place. A safety plan is a set of guidelines to follow in the case of a mental health emergency. It is important to let your provider know if you are at risk of harming yourself or someone else, and to discuss safety planning before an emergency arises.