Fixed so the agent program closes when the master server is closed