When your thread is about to end you need to make the tiny stitch on the back side and make the loop. Use the places where you already stitched so this stitch is not going to be visible on the front side. Go through the loop and make few short stitches on top of existing ones. Then you can cut the thread - your thread is secured.
Here is the video: https://youtu.be/ZR9SkGEQH7A