If you carry a multi-tool which happens to include a chain tool, you could also convert your bike to a single speed. If you do so, you would have to replace the chain afterwards as well (since you shorten it) but in some situations it could get you ourout of a rural area.
If you do so, carefully select the gear you would put it in, as you won't be able to shift anymore afterwards.
There is a nice video online illustrating the idea: how to do a roadside fix of a broken rear derailleur. GCN has some more videos online explaining roadside repairs of various issues, which may also interest you.
Small additional hint:Additionally, I always take a missing link with me, as it allows you to get home after a broken chain. This speed link can also be used while converting your bike to a single speed.