[JBJCA-1101] Fix broken error codes in end()