What is the best way to make sure Array in PHP are closed correctly
It is no longer necessary to put databases into your Drush alias file. In older versions of Drush, a databases record in an alias file could be used to allow Drush to do an sql-sync to or from a remote system that did not have Drush installed.  This feature is no longer supported, and the databases record is no longer necessary.

To answer your specific question, though, any php nested array must have balanced parenthesis.  Make sure that you have one ( for every ). Folks usually keep track of their parenthesis via indentation -- add a level of indentation for each (, and remove it for each ).