any precaution when calling uartclose?

Answer

Besides what mentioned in core manual, yuo should check if the uart is already before calling uartclose. You should also check if there is any remaining data in the uart tx buffer.