Added defence against bad sqlite3 handles to the finalizer