Strings in noncompact spacetimes: Boundary terms and conserved charges