Alright kinda weird, but this was exactly my problem, good news: i got it fixed, and here's how. Your problem which includes stalling and the clicking noise, is by far from normal, it's a faulty throttle body. Bring your car into the dealership and have them inspect the throttle body, there's also a service bulletin out there somewhere concerning this problem, I had them search it up and replace my throttle body, which they did. Basically you can take a look at your throttle body yourself, and see that there are two letters in its line of serial code, which could be "AA," "AB," or "BB." I forgot which ones are the faulty ones, and which one is the good one, but the dealerships are advised to replace the faulty throttle bodies if they do have a problem, and mine certainly did cuz I stalled out 3 times. Not to worry i've shared the same problem and gotten through it, and btw idle that dips down to 500 rpm is not normal at all, it should be a steady 700 rpm w/o the a/c or heater on and w/o the radiator fan spinning.
alright i guess im in a generous mood, i searched and heres the tsb. good luck w/ your problem, and if you dealership gives you any guff about not being able to read the stall code in the car's computer, fuck em, tell them to have the throttle body replaced like north america mazda operations told them to do.
http://www.finishlineperformance.com/mazda6/docs/0043.pdf