Correctly trigger 'on_exit' of starting/initial state

Instead of not calling the 'on_exit' of the initialized
and/or starting state we should make an attempt to call
it if a function exists/was provided. This function will
be called on the first event to be processed (which will
cause the state machine to transition out of the starting
state to a new stable state).

Fixes bug 1404124

Change-Id: I037439313f9071af23c0859a62832d735f9abcd8
Merge "Correctly trigger 'on_exit' of starting/initial state"