Explicitly close SQL statements/connections

SQL connection is closed once the server stops running.
SQL statements are closed after usage.
Added ordering types to party and candidate info queries