Thankfully Estonia is a safe country with a low crime rate but you never know - accidents happen and it might be that you need the help of your embassy or consulate.
Every EU country has an embassy in Tallinn, as does the USA, Canada, Russia and Ukraine. There are also Russian consulates in Tartu and Narva. Their websites give details of the services they offer and relevant contact details.
The numbers given are usually for use during office hours. You can call them at other times, but be ready to note another "emergency" number they will probably give in an answerphone message.
More information about Embassies and Consulates in Estonia
Contact details for all Embassies based in Tallinn, or accredited from other places such as Helsinki or Stockholm, are on the Estonian Ministry of Foreign Affairs website.