cleanups
plug memory leaks

caused by incorrect libcurl usage
also shutdown correctly after CTRL+C/SIGINT