Running asynchronous PHP code
A request to a REST API should just return required data and end. If you want to do asynchronous tasks do not reuse request threads, use cron tasks.

If you want to get independent from Durpal cron use your own drush command executed by a system cron. So, you declare a drush command that makes whatever asyncrhonous tasks and then declare a system cron that runs drush on that command.

If you need to prepare data for that command (for example, if some REST API functions generates data that must be processed asynchronously) you can use Drupal Queues. When the API is called add a new element to a certain queue that will be later processed by the drush command.