Try using the System data-types instead (same code change as required to pass refs).
double *d = new double;
System::Double d = new System::Double;
The exit/atexit problem... a DLL would link to different CRTs than the executable running it, so you would have to some-how get hold of the executable's _exit() function, and link to it from your DLL, if your DLL needs to exit.
Try using the System method for exiting an Application. Although, using C/C++ libraries would still have a problem if you use the .h/.lib method to compile and link.