Quitting the App

To cleanly shut down bevy, send an AppExit event from any system:

use bevy::app::AppExit;

fn exit_system(mut exit: EventWriter<AppExit>) {

For prototyping, bevy provides a system you can add to your App, to close the focused window on pressing the Esc key. When all windows are closed, Bevy will quit automatically.

fn main() {