Fixed possible dead lock when scheduler is interrupted.