If a bulb breaks while in the socket or just drops out and hangs by wires turn of the switch right away. Then unplug the lamp or switch off the circuit.
There are two good way to go from here.
Take a pair of needle nose pliers grasp the edge and twist the bulb out.
Cut a potato in half and push the raw end into the broken glass and twist the bulb out.