Return to the start position
Keys usually only come out in one position. Make sure the key is turned fully back to where you inserted it. In a car ignition, the vehicle may need to be fully in park, and some need the brake pressed or a button released.
Ease, do not yank
Wiggle the key very slightly up and down while drawing it straight out. Do not twist it side to side or pull at an angle; that is how keys snap. For a door, try light pressure on the door toward or away from the frame.
Stop if it resists
If gentle attempts fail, leave the key in place and call. A key that is stuck but whole is much easier to deal with than a broken one.
Why keys get stuck
Common causes are a worn or slightly bent key, debris in the keyway, a door pulling against the bolt, or an ignition not in the right position. Note which of these might apply. That makes the conversation quicker and helps us bring the right approach for your lock or vehicle.