Update database.py

Inverted logic means _release_internal will always fail on a rollback. Fixed and simplified.