Only rollback SQLite transactions when open.

Since SQLite3 will roll back transactions and set the auto-commit
flag, callers must check that flag before issuing a rollback.