Straighten your body, so that your toes are hardly resting on the wall and the rest of your body is close to the wall but no touching it.
Lean slightly forward so that your feet come off the wall and try to balance for a few secondes before leaning on the wall again.
Risks
If you fall forward, you could land on your back. To avoid that, pirouette out of the handstand by moving one hand forward and doing a carthweel. It is also possible to exit by doing a Forward roll but most people prefer exiting by donig a cartwheel.