This is true, but a better rule of thumb is that a script should never end with a php end tag. So you should always omit it.
For the OP, just to explain the reasoning behind this:
The PHP interpreter will automagically close off any PHP script or block when a file ends, removing all whitespace. If however, you create a php script with a standard block like this:
<?php
// Some PHP code
?>
// some whitespace here, or even this "comment" which is actually outside the PHP block and will be treated as text by the parser!
Now you include this in another script ... and what happens? PHP sees the end block, something after it, and starts output. This was (and probably still is) a frequent cause of the "Headers already sent" error that people encounter when using sessions or trying to use the header() function to set HTTP headers. When non-buffered output is generated by PHP, the HTTP header gets sent first, so at that point it is too late to set a cookie or any other HTTP header.
The solution of leaving off the php end tag has been a long time best practice going back to version 5.x at least.
This recommendation was formalized in PSR-2 (since deprecated in favor of PSR-12) so you might want to take a look at the other code standard recommendations from PSR-12, as it's a great set of standards and guidelines for writing and formatting your code. There are also tools that integrate with some of the more used PHP code editors that can reformat your code to fit some or all of these standards.