Protect globals.Stopping with RWMutex.

Make globals.Stopping unexported and wrap writes/reads with methods that lock
on a RWMutex.

Fixes #1025
I think this name should be different, too. We already have a `Shutdown` method, so it's weird to have a `shutdown` method that does something different. `setStopping`, maybe?