Remove trailing PHP closing tags

This commit removes all trailing PHP closing tags ("?>") and extra new
lines; it also add some missing semicolons.

see http://www.php.net/manual/en/language.basic-syntax.instruction-separation.php