fix problem with default value db

@thejefflarson: at_exit of default_db is called after at_exit of @db -> clear had no effect
use two condition variables