I am writing a serial port program, how am i going to stop the program when i can't find the serial port and exit the program without illegal operations..... THAnks!

Sample of the program:

if(!GetCommState(hComm, &dcbCPort))
{cout<<"Error getting com state!"<<endl;
Application->Terminate();
CloseHandle(hComm);
Abort;
;
}
else
cout<<"Port ready to use!"<<endl;

Just remebered, is it ok to use the abort method or is there some other ways to stop the program from process the rest of the codes....???