This seems to come down to a problem with running code after the response is sent. Not a very easy task:
What's the fastest way for a true sinatra(ruby/rack) after_filter?
That said, it looks like you could do something like this (though I haven't tested it):
post '/terminate' do
body "I'll be back..."
# maybe clean things up here...
logger.info "Received terminate request!"
Thread.new { sleep 1; Process.kill 'INT', Process.pid }
halt 200
end
Seems very "hacky", but I question the point of being able to remotely shutdown a web server via a call to a URI anyway. ;-)