Chemical waves in confined regions by Hamilton-Jacobi-Bellman theory