Prevent the end event from firing multiple times.