Add -Wextra and fix additional warnings.
Fix one more warning.
Restrict thread state transitions to avoid possible race condition.

Previously, loom_shutdown could have set a running tasks's state to
LTS_ALERT_SHUTDOWN, then clobbered it with LTS_ACTIVE when entering
run_tasks. Now, if the state is LTS_ALERT_SHUTDOWN, it stays in that
state until the thread begins shutting down and goes into LTS_CLOSING.