stopServerOnCancellation

fun ApplicationEngine.stopServerOnCancellation(application: Application, gracePeriodMillis: Long = 50, timeoutMillis: Long = 5000): CompletableJob

Stop server on job cancellation. The returned CompletableJob needs to be completed or cancelled.