Generally speaking, it is not necessary to close connections, file handles, etc., as they will be closed automatically upon script termination. However, it certainly does not hurt anything to close them as soon as you are finished with them, and it could possibly help minimize resource usage on busy servers and/or when running resource-intensive and/or long-running scripts.