A phase locking mechanism for nongyrotropic electron distributions upstream of the Earth's bow shock