Optimal stopping in a general framework