Add a DISCONNECTING state

This prevents running disconnect hooks more than once.

Note: May break plugins that check connection.disconnected
but then plugins shouldn't do that, probably.
Add resetting flag to transaction

This prevents reset_transaction hooks from stomping over each other.