An explicit solution to an optimal stopping problem with regime switching