Found a solution, think this is right way. Correct me if i make a mistake
UPDATE _thread
SET lastresponse
= NOW() WHERE _thread
.id
= "$a" LIMIT 1; \
UPDATE _ticket
SET lastupdate
= NOW(), closed
= NOW(), status_id
= 3, updated
= NOW() WHERE _ticket
.ticket_id
= "$a" LIMIT 1; \
UPDATE _thread_event
SET annulled
= 1 WHERE _thread_event
.thread_id
= "$a" AND _thread_event
.event_id
= 2; \
INSERT INTO _thread_event
SET thread_type
= 'T', staff_id
= 0, team_id
= 0, dept_id=1
, timestamp
= NOW(), uid_type
= 'S', uid
= 1, username
= 'SYSTEM', event_id
= 2, data
= '{\"status\":[3,\"\u0417\u0430\u043a\u0440\u044b\u0442\u0430\u044f\"]}', thread_id
= "$a";