This fixes a race condition where the block store or the transaction store might be accessed after being closed. To fix this, we wait until all connections are closed before closing the stores.
This race condition is tricky to trigger, but I hit it when writing an extended block acceptance test.