You can do the following:
library(terra)
e <- ext( c(4304916, 4305325, 365216, 365439) )
p <- as.polygons(e)
crs(p) <- "+proj=utm +zone=18 +ellps=GRS80 +datum=NAD83 +units=m"
writeVector(p, 'file.shp')
Or with the raster package
library(raster)
e <- extent( c(4304916, 4305325, 365216, 365439) )
p <- as(e, 'SpatialPolygons')
crs(p) <- "+proj=utm +zone=18 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
shapefile(p, 'file.shp')