diff --git a/src/opus_demo.c b/src/opus_demo.c
index 3ec4b1071aab787974b377a91d6b7d443ad1073b..23c2128f84d1426f339240a3aeff29c9d65fb8ca 100644
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -88,8 +88,8 @@ static void check_decoder_option(int encode_only, const char *opt)
    if (encode_only)
    {
       fprintf(stderr, "option %s is only for decoding\n", opt);
+      exit(EXIT_FAILURE);
    }
-   exit(EXIT_FAILURE);
 }
 
 static void check_encoder_option(int decode_only, const char *opt)
@@ -97,8 +97,8 @@ static void check_encoder_option(int decode_only, const char *opt)
    if (decode_only)
    {
       fprintf(stderr, "option %s is only for encoding\n", opt);
+      exit(EXIT_FAILURE);
    }
-   exit(EXIT_FAILURE);
 }
 
 int main(int argc, char *argv[])