Make deleteDatabase: wait till all threads have closed the DB

I think bugs like #180 and #169 may be caused by the replicator thread
not closing the database till after the main thread has deleted it; this could
result in the file existing and having data in it, which would confuse the
next CBLDatabase instance to open that database name.