add term logic of application to prevent memory leak (for desktop such as linux, mac, windows)