add a function to close application