Excellent. In both the examples you gave, you have a higher energy state dropping to a lower energy state, and energy being applied to raise a lower energy state to a higher energy state. The further apart the two states are, the more energy is required or released when the system changes from one state to another.
Chemical potential energy is similar. Molecules have energy tied up in their bonds and in other interactions, and changing those interactions will either give off energy or require an energy input. A mixture of hydrogen and oxygen molecules, for example, has a higher chemical potential than the same atoms in the form of water. Consequently, under the appropriate conditions, hydrogen and oxygen molecules (high energy state) will spontaneously react to form water (low energy state), giving off energy. Similarly, energy can be added to water in the form of electricity (under the right conditions) to produce hydrogen gas and oxygen gas.