How can I remove a closet shelf & keep it intact?
Most likely nailed from above into braces.  

May be glued and/or caulked, so run a utility knife or window razor (single straight edge razor in a holder).

Then, as suggested by DA01 and Jacob S, wack upwards with a rubber mallet or a regular hammer into a block of wood