Make sure to release connections on error.