Remove race condition from loop() shutdown.  Closes #78.