Before adding the marshmallow, pull the cookies from the oven when they're slightly under-baked. They'll continue to firm up when they go back into the oven with the marshmallows and as they cool.