Transaction(): always attempt to end transaction if ending is set, in methods emit_add(), emit_remove() and emit_nothing()