Implement timeout (resolves #364)