Ensure the write transaction from initializing a realm gets closed

RLMRealmSetSchema throws if a migration is needed but was not provided,
which resulted in the write transaction not being committed until the
realm object was destroyed.