Added check for open transaction on end()