Add a close() function to the main application.