Self-driving spacecraft may save Earth from doomsday