Family policies and the optimal population growth rate: closed and small open economies