Add routines to clean up terra state

The Terra API exposes no way to clean up the resources created by terra_init; I propose a replacement for lua_close to clean up all resources created by the terra instance. Additionally, the compiler state is allocated with new instead, since the structure contains a C++ object.