check: Fixup the shutting down order

First bring down everything to NULL before attempting to unlink
or unref anything.

Avoids the tests just hanging there for ever waiting to acquire a
lock that doesn't exist anymore.
1 file changed