Implement timeout and stop
Tests for timeout and stop