This isn't so much a 'meditation' as an awareness technique.
I suffered years of depression and anxiety and one of the worse things about both was the intrusive thoughts of death that haunted me. At their worst it was a constant battle - dealing with one only to have another one come along a few seconds later.
I often think it helps to have a bit of background and understand a bit about what is going on in the brain so part of my journey to discovering this technique was being aware that the bit of the brain that deals with fear and anxiety is one of the oldest bits of the brain. It operates by sending you images of the danger it has sensed - so that you go in to fight or flight mode. That's great if you need to run away from a bear at the back of the cave but is pretty useless when the danger is stress. One common image sent if you are facing a lot of stress is that of death ... and that just makes you more stressed.
I started to look at what was happening using a visualisation - imagining the thoughts as unwelcome visitors knocking at the door and what I was doing each time was hiding behind the sofa hoping that they would just go away. What I needed to do was open the door and politely tell them that I wasn't interested.
So, my technique for dealing with intrustive thoughts:
a) recognise that your brain is trying to communicate to me that I am stressed but it isn't brilliant at doing that. The intrusive thoughts are warning lights on my dashboard indicating that a problem is coming up if I continue doing what you are doing.
b) don't fight the thought - welcome it as what it is - a warning that I am stressed and need to relax ... and to start off for me that meant thanking my brain for warning me I was stressed. To go back to the dashboard analogy - note the warning and make arrangements to take the car to the garage to have the problem dealt with rather than just carrying on driving and letting the problem get worse.
c) deliberately do something or find something going on around me that makes me feel good and start relaxing for a while.
It doesn't stop the thoughts coming - because they are warnings - but it does enable you to change your reaction to them from a vicious circle of getting more and more stressed to one of recognising the real problem and dealing with it appropriately.