Refactor housekeeping when a master stops

Handle stopped masters (whether expired or normal shutdown) within the
data API.  Be careful to stop steps and logs as well as builds and build
requests, and do so with the data API.
remove uses of .format
use the correct mock method
Merge pull request #1408 from djmitche/bug3073

Refactor housekeeping when a master stops