Fixed return codes and DX null pointer during exit.