Self-terminating diffraction gates femtosecond X-ray nanocrystallography measurements