tty, serial: Fix race and NULL check in uart_close()