Check if devops is valid before closing the device

This fixes a segfault that occurs on exit if tinc fails before the device is initialized (for example, if it fails to read the private key).