/* Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a SHELL_FILE_HANDLE to support redirecting output from a file. */
EFI_STATUS CloseSimpleTextOutOnFile(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut)
/* Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a SHELL_FILE_HANDLE to support redirecting output from a file. */
EFI_STATUS CloseSimpleTextOutOnFile(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut)
{
  EFI_STATUS  Status;
  if (SimpleTextOut == NULL) {
    return (EFI_INVALID_PARAMETER);
  }
  Status = gBS->UninstallProtocolInterface (
                  ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->TheHandle,
                  &gEfiSimpleTextOutProtocolGuid,
                  &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->SimpleTextOut)
                  );
  FreePool (SimpleTextOut->Mode);
  FreePool (SimpleTextOut);
  return (Status);
}