Kyrgyz president resigns to avoid bloodshed