A 7.7-magnitude earthquake in eastern Indonesia killed at least 40 people and caused widespread panic.