freeing kernel at termination