Free memory that has been allocated for each thread.