How to Exit a Dart Application Unconditionally? Last Updated : 15 Jul, 2025 Comments Improve Suggest changes 7 Likes Like Report The exit() method exits the current program by terminating the running Dart VM. This method takes a status code. A non-zero value of status code is generally used to indicate abnormal termination. This is a similar exit in C/C++, Java. This method doesn't wait for any asynchronous operations to terminate.Syntax: exit(exit_code);To use this method, we have to import 'dart:io' package. The handling of exit codes is platform-specific.On Linux and OS, an exit code for normal termination will always be in the range of 0 to 255. If an exit code outside this range is set the actual exit code will be the lower 8 bits masked off and treated as an unsigned value. E.g. using an exit code of -1 will result in an actual exit code of 255 being reported.On Windows, the exit code can be set to any 32-bit value. However, some of these values are reserved for reporting system errors like crashes. Besides this, the Dart executable itself uses an exit code of 254 for reporting compile-time errors and an exit code of 255 for reporting runtime errors (unhandled exceptions). Due to these facts, it is recommended to only use exit codes in the range of 0 to 127 for communicating the result of running a Dart program to the surrounding environment. This will avoid any cross-platform issues.Note: The exit(0) is generally used to indicate successful termination, while the rest generally indicates unsuccessful termination.Implementation of the exit() method is as: Dart void exit(int code) { ArgumentError.checkNotNull(code, "code"); if (!_EmbedderConfig._mayExit) { throw new UnsupportedError("This embedder disallows calling dart:io's exit()"); } _ProcessUtils._exit(code); } Using the exit() method to exit the program abruptly Example: Dart // Importing the packages import 'dart:io'; // Main Function void main() { // This will be printed print("Hello GeeksForGeeks"); // Standard out code exit(0); // This will not be printed print("Good Bye GeeksForGeeks"); } Output:Hello GeeksForGeeks Comment A aditya_taparia Follow 7 Improve A aditya_taparia Follow 7 Improve Article Tags : Dart Dart-basics Explore Dart Tutorial 7 min read BasicsIntroduction to Dart Programming Language 4 min read Dart SDK Installation 4 min read Dart - Comments 2 min read Dart - Variables 5 min read Operators in Dart 11 min read Dart - Standard Input Output 3 min read Data TypesDart - Data Types 8 min read Basics of Numbers in Dart 6 min read Strings in Dart 6 min read Dart - Sets 6 min read Dart Programming - Map 7 min read Queues in Dart 3 min read Data Enumeration in Dart 3 min read Control FlowSwitch Case in Dart 2 min read Dart - Loops 4 min read Dart - Loop Control Statements (Break and Continue) 4 min read Labels in Dart 2 min read Key FunctionsDart - Anonymous Functions 2 min read Dart - main() Function 2 min read Dart - Common Collection Methods 2 min read How to Exit a Dart Application Unconditionally? 2 min read Dart - Getters and Setters 3 min read Dart - Classes And Objects 4 min read Object-Oriented ProgrammingDart - this keyword 2 min read Dart - Static Keyword 3 min read Dart - Super and This keyword 4 min read Dart - Concept of Inheritance 5 min read Instance and class methods in Dart 3 min read Method Overriding in Dart 3 min read Getter and Setter Methods in Dart 2 min read Abstract Classes in Dart 4 min read Dart - Builder Class 4 min read Concept of Callable Classes in Dart 4 min read Interface in Dart 3 min read Dart - extends Vs with Vs implements 4 min read Dart - Date and Time 3 min read Using await async in Dart 4 min read Dart UtilitiesHow to Combine Lists in Dart? 3 min read Dart - Finding Minimum and Maximum Value in a List 5 min read Dart - Splitting of String 1 min read Dart ProgramsDart - Sort a List 2 min read Dart - String toUpperCase() Function with Examples 1 min read Dart - Convert All Characters of a String in Lowercase 1 min read How to Replace a Substring of a String in Dart? 2 min read How to Check String is Empty or Not in Dart (Null Safety)? 1 min read Exception Handling in Dart 3 min read Assert Statements in Dart 3 min read Fallthrough Condition in Dart 3 min read Concept of Isolates in Dart 2 min read Advance ConceptsDart - Collections 7 min read Dart - Basics of Packages 2 min read Dart - String codeUnits Property 1 min read HTML Document Object Model and Dart Programming 3 min read Like