Add timeout to environment.

Port of erlang_js#33. @russelldb