After receiving a rejection (not revise and resubmit) decision from the editor/associate editor of a journal, should we write an email to thank him/her for the time, or just do nothing? I imagine one might do that out of courtesy, but then I don't really have much to say otherwise.
I believe that if you feel the rejection was unjustified and you do not plan to submit to that journal again, you do not need to reply.
But if you feel the rejection was justified, you plan to submit to that journal again, or you were helped by the comments and suggestions of the referees, then I would recommend that you write an e-mail thanking the editor and the referees for their time and effort.
I think it is reasonable to thank editors that keep you up to date, solicit reviews in a timely manner, and provide an understandable overview of the reviews. Unfortunately, the number of good editors is small, so I would caution against thanking editors for merely acting as editor. The benefits are small while the potential cost is huge. It is so atypical that you run the risk of the editor thinking you are whining.