Added end callback to close pg connection.