Its whole poo fight. Your body is sent to BKK police forensic hospital by local police who liaise with the doctor after they pronounce death. the police inform your embassy who will inform your next of kin.
Now it depends on where you want to be buried/cremated. After that the death certificate must be obtained from the FPH and brought to the Amphur where you died to register your death, only then can your body be released.
Then it depends where the funeral will take place, one had to arrange for the body to be transported to your favored place of the ceremony.
*OR right from the time of death, contact a funeral director, recommended by by your Embassy to do all of the work, I can't recommend anything better. 'Asia-one' were the directors that we used for my friend, and they were very helpful in everyway.