Stop function waits until all write operations are finished