very carefully with a pair of needle nose pliers n a box cutter works. just pulling it may pull the stinger off or break it. use a towel to hold the tail n be very careful. never got hit but i remember river monsters... ouch
If it is infected and growing a white fungus on it then you should remove it. Otherwise just wait for the ray to shed its barb and take it out of the tank then.