An earthquake shook parts of several northeastern states, including Maine, according to the U.S. Geological Survey.