Handles exceptions properly in background writer.

.NET 4.5 won't kill the appdomain when a task failure goes unobserved, but
we should still ensure that it never happens. The tests should fail loudly
if this ever does occur.

The use of spinwaits is pointless complication in CloseAsync since we
don't expect lots of threads to contend on that method anyway.
BackgroundWriter must not keep itself alive.

The TaskScheduler holds a permanent reference to the BackgroundWriter
task. If the block chain is not disposed then the task will never
terminate. Symptom: NCrunch task runners permanently busy running tests
which never complete.

By separating the WritableBlockChain from the Writer task, we can use the
finalisation of the block chain as a trigger for the Writer to shut down.
LivenessIndicator encapsulates the abort token as well as a weak reference
to a marker object, which is strongly referenced by the Writer via a
struct. When the struct releases the strong reference, it is only a matter
of time before the Writer notices that its parent block chain has died and
shuts itself down too.
Guarantee that commitReady does not get missed.

Checking commitReady inside the lock is subject to a race condition where
the flag is set after the lock owner has checked it but after the setter
has failed to acquire the lock.

Checking it after releasing the lock guarantees one of the following
cases instead:
* Setter A fails to acquire lock and returns. Lock owner B releases lock,
  reacquires lock and commits.
* Setter A fails to acquire lock and returns. Lock owner B releases lock.
  Setter C acquires lock. Lock owner B resets flag and fails to reacquire
  lock. Setter C commits.

I was unable to devise a test case for this, but NCrunch's task runners
were still getting stuck and the debugger turned up some 'impossible'
system state caused by this race. No longer happens after this change.