Ending the aplication

How can I end the application automatically in 5 seconds ?

use ofTimer and when timer expires use ofExit()

You need to create a timer and then call exit(). Make sure that you define void exit() in your ofApp.h and ofApp.cpp. exit() is a virtual function from ofBaseApp, so just creating it it will do what you need.

//ofApp.h
void exit();
float time;
float timeLimit;

//ofApp.cpp
void ofApp::setup(){

 timeLimit = 5;// this represents the five seconds you want to set as a flag to call
 time = 0;// always a good practice to define your variables in setup.

}

void ofApp::exit(){

}

void ofApp::update(){

 time = ofGetElapsedTimef();// this functions keep track of the time in seconds once the application has initialized.
 
 if ( time >= timeLimit){//if the current time is equal or greater than 5 seconds...

   exit();//we exit the application.
   //if you can also call ofExit() as Gallo suggested.

 }
}