Async While Loop Javascript Break Function Matlab