diff --git a/apps/efka/src/efka_agent.erl b/apps/efka/src/efka_agent.erl index a7c3b9e..70f7714 100644 --- a/apps/efka/src/efka_agent.erl +++ b/apps/efka/src/efka_agent.erl @@ -400,7 +400,13 @@ handle_event(info, {'DOWN', MRef, process, TransportPid, Reason}, _, State = #st %% terminate. It should be the opposite of Module:init/1 and do any %% necessary cleaning up. When it returns, the gen_statem terminates with %% Reason. The return value is ignored. -terminate(_Reason, _StateName, _State = #state{}) -> +terminate(_Reason, _StateName, _State = #state{transport_pid = TransportPid}) -> + case is_pid(TransportPid) andalso is_process_alive(TransportPid) of + true -> + efka_transport:stop(TransportPid); + false -> + ok + end, ok. %% @private