Added a call to fgDeinitialize() before the call to exit() in fgError().