Commits all changes to the database and ends the transaction