Handle exit event, by stopping devices and disconnecting connections

Handle exit event, by stopping devices and disconnecting connections