diff --git a/examples/nfc-dep-initiator.c b/examples/nfc-dep-initiator.c index acf6e31..c34ea6c 100644 --- a/examples/nfc-dep-initiator.c +++ b/examples/nfc-dep-initiator.c @@ -53,10 +53,12 @@ static nfc_device *pnd; static void stop_dep_communication(int sig) { (void) sig; - if (pnd != NULL) + if (pnd != NULL) { nfc_abort_command(pnd); - else + } else { + nfc_exit(context); exit(EXIT_FAILURE); + } } int diff --git a/examples/nfc-dep-target.c b/examples/nfc-dep-target.c index d238a27..b91ec18 100644 --- a/examples/nfc-dep-target.c +++ b/examples/nfc-dep-target.c @@ -52,10 +52,12 @@ static nfc_device *pnd; static void stop_dep_communication(int sig) { (void) sig; - if (pnd != NULL) + if (pnd != NULL) { nfc_abort_command(pnd); - else + } else { + nfc_exit(context); exit(EXIT_FAILURE); + } } int diff --git a/examples/nfc-emulate-forum-tag2.c b/examples/nfc-emulate-forum-tag2.c index f76ca44..cdd430e 100644 --- a/examples/nfc-emulate-forum-tag2.c +++ b/examples/nfc-emulate-forum-tag2.c @@ -82,6 +82,7 @@ stop_emulation(int sig) if (pnd != NULL) { nfc_abort_command(pnd); } else { + nfc_exit(context); exit(EXIT_FAILURE); } } diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index 68e8766..42c9a10 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -66,6 +66,9 @@ intr_hdlr(int sig) { (void) sig; printf("\nQuitting...\n"); + if (pnd != NULL) { + nfc_abort_command(pnd); + } nfc_close(pnd); nfc_exit(context); exit(EXIT_FAILURE); diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 7c2d079..0f885bb 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -58,8 +58,10 @@ static void stop_polling(int sig) (void) sig; if (pnd != NULL) nfc_abort_command(pnd); - else + else { + nfc_exit(context); exit(EXIT_FAILURE); + } } static void diff --git a/utils/nfc-emulate-forum-tag4.c b/utils/nfc-emulate-forum-tag4.c index cfd94e7..f604388 100644 --- a/utils/nfc-emulate-forum-tag4.c +++ b/utils/nfc-emulate-forum-tag4.c @@ -237,10 +237,12 @@ nfcforum_tag4_io(struct nfc_emulator *emulator, const uint8_t *data_in, const si static void stop_emulation(int sig) { (void) sig; - if (pnd != NULL) + if (pnd != NULL) { nfc_abort_command(pnd); - else + } else { + nfc_exit(context); exit(EXIT_FAILURE); + } } static int diff --git a/utils/nfc-read-forum-tag3.c b/utils/nfc-read-forum-tag3.c index 27ce150..720ff6a 100644 --- a/utils/nfc-read-forum-tag3.c +++ b/utils/nfc-read-forum-tag3.c @@ -72,10 +72,12 @@ print_usage(char *progname) static void stop_select(int sig) { (void) sig; - if (pnd != NULL) + if (pnd != NULL) { nfc_abort_command(pnd); - else + } else { + nfc_exit(context); exit(EXIT_FAILURE); + } } static void