Added delayed application quit.

For proper application quit event sending, a different approach for
application quit handling has been created.