Leaving him in the gym while you're not playing will complete his training.
You will receive a notification to confirm that it has finished and  then you can continue raising levels.

Once you enter the shelter you will see a symbol on the dweller you left in the gym indicating that he is ready, you must click on him and he will be able to continue training, if not, regardless of whether he has already gone up a level, he will not be able to continue doing so.