Terminate the application
When the user closes the Falling Blocks application, we need to do some cleaning up to make sure the application shuts down properly. When an application receives a NAVIGATOR_EXIT event, the system directs the application to start shutting down. The application then has a certain amount of time (about 500 ms) to save its state and perform any additional cleanup operations. After this time has elapsed, if the application hasn't terminated yet, the system terminates it.
- Stop requesting events from the screen.
- Shut down the BPS library, because we no longer need any BPS functions for the application. It's important to remember that after you perform this step, your application shouldn't call any other BPS functions.
- Free the memory that was allocated for the blocks. Because we used malloc() to allocate the memory, we should free it manually to make sure that we don't create a memory leak. The system should deallocate this memory anyways, but it's good practice to do it explicitly when we're done using it.
- Invoke bbutil_terminate(). This function cleans up the EGL setup by performing tasks such as destroying the EGL surface, context, and libscreen window.
- Destroy the screen context, and exit the application.
screen_destroy_context(screen_cxt); return 0;